9.5
Release 9.5 introduces 9 new rules for C# and VB.NET developers, providing guidelines and best practices for handling date and time operations within their applications.
These rules cover a wide range of topics, including time zone conventions, common pitfalls, date parsing and formatting, time arithmetic, and more.
This release includes also one additional security rule and introduces fixes for false negatives and false positives.
Thanks to @Corniel for his contribution by implementing a new codefix for S6610 (#7517) and fixing a FP in S6354 (#7504).
New Rules
Date & time
- 7080 - [C#, VB.NET] New rule S6588: Use
DateTime(Offset).UnixEpoch
instead of pointing to that date using the constructor - 7085 - [C#, VB.NET] New rule S6566: Always use
DateTimeOffset
instead ofDateTime
- 7083 - [C#, VB.NET] New rule S6561: Do not use
DateTime.Now
for benchmarking or timing operations - 7081 - [C#, VB.NET] New rule S6562: Always set the
DateTimeKind
when creating a newDateTime
object - 7079 - [C#, VB.NET] New rule S6585: Don't hardcode the format provider when turning dates and times to string
- 7078 - [C#, VB.NET] New Rule S6580: Always use
DateTime.Parse
overloads with anIFormatProvider
parameter - 7077 - [C#, VB.NET] New rule S6575: Use
TimeZoneInfo.FindSystemTimeZoneById
instead ofTimezoneConverter
- 7076 - [C#, VB.NET] New Rule S6563: Use UTC when recoding
DateTime
instants - 7490|7086 - [C#, VB.NET] New rule S3363: Date and time should not be used as types for primary keys
Others
Improvements
- 7516 - [C#, VB.NET] Rule S6588: implement CodeFix
- 7517 - [C#] Rule S6610: implement CodeFix
- 7469 - SE: Run for local functions
- 7468 - SE: Run for Top-Level statements
False Positive
- 7504 - [C#, VB.NET] Fix S6354 FP: Do not report on XML crefs and nameof
- 6223 - [C#, VB.NET] Fix S5332 FP: Improve detection of namespace uris