Skip to content

Conversation

@jsrustad
Copy link

@jsrustad jsrustad commented Oct 29, 2025

Refactor: Use pattern matching for type checks

Refactored code to utilize C# pattern matching with the is keyword for type checking and casting, eliminating explicit casts.

  • Updated ElementOrderCodeFixProvider.cs to use pattern matching for TypeDeclarationSyntax and CompilationUnitSyntax.
  • Refactored Equals method in UsingCodeFixProvider.TreeTextSpan.cs to use pattern matching.
  • Applied pattern matching in DeclarationModifiersHelper.cs for various syntax types, improving readability and maintainability.

Closes #3951

Refactor: Use pattern matching for type checks

Refactored code to utilize C# pattern matching with the `is` keyword for type checking and casting, eliminating explicit casts.
- Updated `ElementOrderCodeFixProvider.cs` to use pattern matching for `TypeDeclarationSyntax` and `CompilationUnitSyntax`.
- Refactored `Equals` method in `UsingCodeFixProvider.TreeTextSpan.cs` to use pattern matching.
- Applied pattern matching in `DeclarationModifiersHelper.cs` for various syntax types, improving readability and maintainability.
@jsrustad jsrustad changed the title Fixed 9 instance of code causing IDE0038 Fixes DotNetAnalyzers/StyleCopAnalyzers#3951 - 9 instance of code causing IDE0038 Oct 29, 2025
@jsrustad jsrustad changed the title Fixes DotNetAnalyzers/StyleCopAnalyzers#3951 - 9 instance of code causing IDE0038 Fixes 9 instance of code causing IDE0038 Oct 29, 2025
@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

❌ Patch coverage is 88.23529% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.46%. Comparing base (673de60) to head (d35f76e).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3952      +/-   ##
==========================================
+ Coverage   94.60%   97.46%   +2.85%     
==========================================
  Files        1026     1026              
  Lines      119110   119137      +27     
  Branches     3475     3475              
==========================================
+ Hits       112684   116114    +3430     
+ Misses       5366     2011    -3355     
+ Partials     1060     1012      -48     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Successfully merging this pull request may close these issues.

IDE0038 Fix code to not cause IDE0038 warning

1 participant