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.44%. Comparing base (f5843ae) to head (bcc7b3d).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3952   +/-   ##
=======================================
  Coverage   97.44%   97.44%           
=======================================
  Files         926      931    +5     
  Lines      110283   110323   +40     
  Branches     3319     3319           
=======================================
+ Hits       107467   107507   +40     
  Misses       1847     1847           
  Partials      969      969           
🚀 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