-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
Description
Describe the bug
- The C# codebase is not utilizing many of the latest features and best practices provided by recent C# versions (C# 10, 11, and 12). This leads to less maintainable, less efficient, and more verbose code. Examples include missing file-scoped namespaces, absence of global using directives, lack of nullable reference types, and other modern syntax improvements.
To Reproduce
- Review files such as Geohash.cs, ListBasedStack.cs, Timeline.cs, BinarySearchTree.cs, and Luhn.cs.
- Observe that the following are missing in many files:
- File-scoped namespaces
- Global using statements
- Raw string literals
- Primary constructors / collection expressions
- Pattern matching and switch expressions
- Required properties and nullable reference types
- Span/ReadOnlySpan for performance
- Compare current implementations to the latest C# standards and best practices.
Expected behavior
- The codebase should leverage modern C# features for improved maintainability, performance, and readability. Examples:
- Use file-scoped namespaces and global using directives
- Adopt pattern matching, switch expressions, and collection expressions
- Enable nullable reference types, use required properties where appropriate
- Refactor code to use Span/ReadOnlySpan for better performance
- Remove unused using statements and update initializations
Actual behavior
- The codebase currently uses older C# constructs, resulting in unnecessary verbosity, missed performance improvements, and more complicated maintenance. Modern constructs are not consistently applied across files.