mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
[PTRun][Calculator] Fix CA1874 warning in CalculateEngine
This commit is contained in:
@@ -11,7 +11,7 @@ using Mages.Core;
|
||||
|
||||
namespace Microsoft.PowerToys.Run.Plugin.Calculator
|
||||
{
|
||||
public class CalculateEngine
|
||||
public partial class CalculateEngine
|
||||
{
|
||||
private readonly Engine _magesEngine = new Engine(new Configuration
|
||||
{
|
||||
@@ -45,7 +45,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator
|
||||
|
||||
// check for division by zero
|
||||
// We check if the string contains a slash followed by space (optional) and zero. Whereas the zero must not be followed by a dot, comma, 'b', 'o' or 'x' as these indicate a number with decimal digits or a binary/octal/hexadecimal value respectively. The zero must also not be followed by other digits.
|
||||
if (new Regex("\\/\\s*0(?!(?:[,\\.0-9]|[box]0*[1-9a-f]))", RegexOptions.IgnoreCase).Match(input).Success)
|
||||
if (DivisionByZeroRegex().IsMatch(input))
|
||||
{
|
||||
error = Properties.Resources.wox_plugin_calculator_division_by_zero;
|
||||
return default;
|
||||
@@ -124,5 +124,8 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[GeneratedRegex("\\/\\s*0(?!(?:[,\\.0-9]|[box]0*[1-9a-f]))", RegexOptions.IgnoreCase, "en-US")]
|
||||
private static partial Regex DivisionByZeroRegex();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user