-
Notifications
You must be signed in to change notification settings - Fork 247
Enable CA1305 warnings and fix them
#794
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
Conversation
Codecov ReportAttention: Patch coverage is ❌ Your project status has failed because the head coverage (67%) is below the target coverage (80%). You can increase the head coverage or adjust the target coverage. @@ Coverage Diff @@
## main #794 +/- ##
===================================
Coverage 67% 67%
===================================
Files 105 105
Lines 4414 4419 +5
Branches 1060 1060
===================================
+ Hits 2936 2940 +4
- Misses 1044 1045 +1
Partials 434 434
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
b6c1018 to
a636a61
Compare
* Add package Microsoft.CodeAnalysis.NetAnalyzers (for build only) * Add `dotnet_diagnostic.CA1305.severity = warning` to .editorconfig * Fix `CA1305` warning or disable where appropriate
a636a61 to
8e868f5
Compare
minichma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this was fast. Just a note on string interpolation. In a work project we have some utility method like the following:
public static string Invariant(IFormattable v)
=> (v == null) ? null : v.ToString(null, CultureInfo.InvariantCulture);This can be used to make string interpolation culture invariant like so:
Invariant($"{...}")
Maybe an option instead of the pragmas.
6ee7fd9 to
11d3840
Compare
|
Thanks for the hint. We can also use the built-in sb.Append(FormattableString.Invariant($"{sign * (ts.Hours)}H"));directly. I was not aware of that. Here the compiler automatically creates a FormattableString fs = $"{sign * (ts.Hours ?? 0)}H";
sb.Append(FormattableString.Invariant(fs));From NET6.0 the right way seems to be (according to SonarCloud) |
|
Very nice and good to know, haven't been aware of that either. |



Microsoft.CodeAnalysis.NetAnalyzers(for build only)dotnet_diagnostic.CA1305.severity = warningto .editorconfigCA1305warning or disable with pragma where appropriateResolves #792