Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Globalization;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Diagnostics.Analyzers.NamingStyles;
Expand Down Expand Up @@ -67,7 +68,7 @@ public static bool IsAnalysisLevelGreaterThanOrEquals(this AnalyzerConfigOptions
const string AnalysisLevelKey = "build_property.EffectiveAnalysisLevelStyle";

return analyzerConfigOptions.TryGetValue(AnalysisLevelKey, out var value)
&& double.TryParse(value, out var version)
&& double.TryParse(value, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out var version)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like I have worked in codebases in the past where all of the 'format' and 'parse' methods involving strings would have an analyzer to mandate the use of an IFormatProvider; is this something where we should check to see if the rule is enabled?

Copy link
Member Author

@jjonescz jjonescz Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found CA1305 but when I've tried enabling it, it didn't catch double.TryParse anyway (perhaps because the overload with IFormatProvider has also the additional NumberStyles parameter).

&& version >= minAnalysisLevel;
}
}
Loading