Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Refactoring with C#

You're reading from  Refactoring with C#

Product type Book
Published in Nov 2023
Publisher Packt
ISBN-13 9781835089989
Pages 434 pages
Edition 1st Edition
Languages
Author (1):
Matt Eland Matt Eland
Profile icon Matt Eland

Table of Contents (24) Chapters

Preface Part 1: Refactoring with C# in Visual Studio
Chapter 1: Technical Debt, Code Smells, and Refactoring Chapter 2: Introduction to Refactoring Chapter 3: Refactoring Code Flow and Iteration Chapter 4: Refactoring at the Method Level Chapter 5: Object-Oriented Refactoring Part 2: Refactoring Safely
Chapter 6: Unit Testing Chapter 7: Test-Driven Development Chapter 8: Avoiding Code Anti-Patterns with SOLID Chapter 9: Advanced Unit Testing Chapter 10: Defensive Coding Techniques Part 3: Advanced Refactoring with AI and Code Analysis
Chapter 11: AI-Assisted Refactoring with GitHub Copilot Chapter 12: Code Analysis in Visual Studio Chapter 13: Creating a Roslyn Analyzer Chapter 14: Refactoring Code with Roslyn Analyzers Part 4: Refactoring in the Enterprise
Chapter 15: Communicating Technical Debt Chapter 16: Adopting Code Standards Chapter 17: Agile Refactoring Index Other Books You May Enjoy

Testing Code Fixes with RoslynTestKit

In Chapter 13, we saw how the RoslynTestKit library helps your diagnostic analyzers flag code issues appropriately. In this chapter, we’ll revisit the library to verify our new code fix.

We will start by creating a new class in our test project named ToStringCodeFixTests due to our common naming conventions.

This class will start by declaring a test fixture like it did with the analyzer:

using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using RoslynTestKit;
namespace Packt.Analyzers.Tests;
public class ToStringCodeFixTests : CodeFixTestFixture {
 protected override string LanguageName
   => LanguageNames.CSharp;
 protected override CodeFixProvider CreateProvider()
   => new ToStringCodeFix();
 protected override IReadOnlyCollection<DiagnosticAnalyzer>
   CreateAdditionalAnalyzers()
   => new[]...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}