From e27202a2a037d8da463ed52e9211717cd35154f0 Mon Sep 17 00:00:00 2001 From: Paul DeVito Date: Thu, 1 Oct 2026 17:19:54 +0300 Subject: [PATCH] fix(operators)!: mark ArithmeticOperator.FromSymbol as obsolete QueryKit does not use the public method ArithmeticOperator.FromSymbol. Mark it obsolete, so that callers get a warning before the next major version removes it. BREAKING CHANGE: a call to ArithmeticOperator.FromSymbol now gives warning CS0618. A project that treats warnings as errors does not compile. Map the symbol to ArithmeticOperator.Add, Subtract, Multiply, Divide, or Modulo in your own code. --- QueryKit.UnitTests/ArithmeticOperatorTests.cs | 4 ++++ QueryKit/Operators/ArithmeticOperator.cs | 1 + 2 files changed, 5 insertions(+) diff --git a/QueryKit.UnitTests/ArithmeticOperatorTests.cs b/QueryKit.UnitTests/ArithmeticOperatorTests.cs index e5444c2..e53be63 100644 --- a/QueryKit.UnitTests/ArithmeticOperatorTests.cs +++ b/QueryKit.UnitTests/ArithmeticOperatorTests.cs @@ -13,7 +13,9 @@ public class ArithmeticOperatorTests [InlineData("%", "%")] public void from_symbol_returns_the_operator_for_the_symbol(string symbol, string expectedSymbol) { +#pragma warning disable CS0618 // FromSymbol stays for v1.14.2 compatibility var op = ArithmeticOperator.FromSymbol(symbol); +#pragma warning restore CS0618 op.Should().NotBeNull(); op!.Symbol.Should().Be(expectedSymbol); @@ -22,7 +24,9 @@ public void from_symbol_returns_the_operator_for_the_symbol(string symbol, strin [Fact] public void from_symbol_returns_null_for_an_unknown_symbol() { +#pragma warning disable CS0618 // FromSymbol stays for v1.14.2 compatibility var op = ArithmeticOperator.FromSymbol("^"); +#pragma warning restore CS0618 op.Should().BeNull(); } diff --git a/QueryKit/Operators/ArithmeticOperator.cs b/QueryKit/Operators/ArithmeticOperator.cs index 70be3fb..0fa6452 100644 --- a/QueryKit/Operators/ArithmeticOperator.cs +++ b/QueryKit/Operators/ArithmeticOperator.cs @@ -24,6 +24,7 @@ protected ArithmeticOperator(string symbol, int precedence) public static ArithmeticOperator Divide => new DivideOperator(); public static ArithmeticOperator Modulo => new ModuloOperator(); + [Obsolete("QueryKit does not use FromSymbol. The next major version removes it.")] public static ArithmeticOperator? FromSymbol(string symbol) => symbol switch { "+" => Add,