mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 11:46:30 +02:00
User/ryanbod/enable codeanalysis for calculatorplugin (#5130)
* Turning on static analysis and removing warning for NoMages. * Fixing static analysis errors in NumberTranslator.cs * Fix: Severity Code Description Project File Line Suppression State Error CA1810 Initialize all static fields in 'Main' when those fields are declared and remove the explicit static constructor Microsoft.Plugin.Calculator C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Calculator\Main.cs 30 Active * Throwing exception if arguments are null to fix static analysis errors. * Ignoring CA1031 * Logging exceptions for Calculator queries.
This commit is contained in:
committed by
GitHub
parent
b59ec5e78b
commit
25d43354b3
@@ -36,6 +36,16 @@ namespace Microsoft.Plugin.Calculator
|
||||
/// <returns></returns>
|
||||
public static NumberTranslator Create(CultureInfo sourceCulture, CultureInfo targetCulture)
|
||||
{
|
||||
if (sourceCulture == null)
|
||||
{
|
||||
throw new ArgumentNullException(paramName:nameof(sourceCulture));
|
||||
}
|
||||
|
||||
if (targetCulture == null)
|
||||
{
|
||||
throw new ArgumentNullException(paramName: nameof(sourceCulture));
|
||||
}
|
||||
|
||||
bool conversionRequired = sourceCulture.NumberFormat.NumberDecimalSeparator != targetCulture.NumberFormat.NumberDecimalSeparator
|
||||
|| sourceCulture.NumberFormat.PercentGroupSeparator != targetCulture.NumberFormat.PercentGroupSeparator
|
||||
|| sourceCulture.NumberFormat.NumberGroupSizes != targetCulture.NumberFormat.NumberGroupSizes;
|
||||
@@ -51,7 +61,7 @@ namespace Microsoft.Plugin.Calculator
|
||||
/// <returns></returns>
|
||||
public string Translate(string input)
|
||||
{
|
||||
return this.Translate(input, this.sourceCulture, this.targetCulture, this.splitRegexForSource);
|
||||
return Translate(input, this.sourceCulture, this.targetCulture, this.splitRegexForSource);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -61,10 +71,10 @@ namespace Microsoft.Plugin.Calculator
|
||||
/// <returns></returns>
|
||||
public string TranslateBack(string input)
|
||||
{
|
||||
return this.Translate(input, this.targetCulture, this.sourceCulture, this.splitRegexForTarget);
|
||||
return Translate(input, this.targetCulture, this.sourceCulture, this.splitRegexForTarget);
|
||||
}
|
||||
|
||||
private string Translate(string input, CultureInfo cultureFrom, CultureInfo cultureTo, Regex splitRegex)
|
||||
private static string Translate(string input, CultureInfo cultureFrom, CultureInfo cultureTo, Regex splitRegex)
|
||||
{
|
||||
var outputBuilder = new StringBuilder();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user