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

Modernise C# #5607

Merged
merged 1 commit into from
Apr 23, 2023
Merged

Modernise C# #5607

merged 1 commit into from
Apr 23, 2023

Conversation

benaadams
Copy link
Member

@benaadams benaadams commented Apr 23, 2023

Changes

  • Use range syntax for .Substring and Slice
  • Compound assignment statements like ??= null check assign operator
  • Use Array.Empty<T>() where appropriate
  • Use .Contains rather than .IndexOf(...) < 0
  • Don't throw from inside finally block
  • Move type declaration into out param
  • Use is not where appropriate
  • Improved use around ValueTuples
  • ContainsKey+Remove on dict to just Remove as it returns bool
  • Use _ discards where the result is ignored
  • Use full pattern matching for type checking + use
  • Use more efficient char '@' string param methods than "@" string where only one char
  • Use ?. null conditional operator rather than more verbose checking

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: Description

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

@rubo rubo self-requested a review April 23, 2023 17:32
@benaadams benaadams merged commit de4b197 into master Apr 23, 2023
@benaadams benaadams deleted the Update-C# branch April 23, 2023 17:44
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.

2 participants