Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Equivalent functionality in VS 2022, .NET 8, and Menees.Analyzers #52

Open
menees opened this issue Mar 29, 2024 · 0 comments
Open

Equivalent functionality in VS 2022, .NET 8, and Menees.Analyzers #52

menees opened this issue Mar 29, 2024 · 0 comments

Comments

@menees
Copy link

menees commented Mar 29, 2024

I've been using C# Essentials since 2015. Since it has no official NuGet package, I've been reluctantly checking the DLL into source control to ensure it's available in every developer's environment. Recently, I got tired of doing that and decided to see what it would take to replace C# Essentials. In the Q&A section on C# Essentials - Visual Studio Marketplace, @DustinCampbell said on Nov 21, 2017:

There's not a need to support this extension for VS 2017 because most of its features are already included in VS itself. With the latest updates to VS 2017, you'll find that there are several code fixes and refactorings for transitioning your code to C# 7.

In Visual Studio 2022 and .NET 8, I found four of the five C# Essentials features built-in:

  • UseNameOf (CSE0001) - .NET includes rule CA1507: Use nameof in place of string.
  • UseExpressionBodiedMember (CSE0003) - VS provides the "Use expression body for method" refactoring
  • ExpandExpressionBodiedMemberRefactoring - VS provides the "Use block body for method" refactoring
  • ConvertToInterpolatedString - VS provides the "Convert to interpolated string" refactoring

So, the only thing missing was UseGetterOnlyAutoProperty (CSE0002). I reimplemented it in my Menees.Analyzers library in release 3.1.0. I had to rewrite it to be compliant with modern Roslyn coding practices (e.g., to avoid GetSemanticModel per rule RS1030). I took the opportunity to make it ignore properties with attributes since they're typically used with reflection and/or serialization. I also updated it to handle some new C# syntax, e.g., null-coalescing assignment, local functions, and record types. And I made the code fixer handle some whitespace formatting cases better.

I hope this helps folks looking for equivalent functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant