From f073813c97ad6f0ba9a84a202fb9c0ad3b2ece40 Mon Sep 17 00:00:00 2001 From: Rafael Vuijk Date: Sun, 9 Aug 2026 18:24:02 +0000 Subject: [PATCH] Move to AngouriMath 2.0, which renamed Latexise to Latexize AngouriMath 2.0 renames ILatexiseable.Latexise to ILatexizeable.Latexize. MathItem implements the new interface explicitly, so CSharpMath's own public surface does not change: MathItem.Latexise stays the name callers know, and PublicAPI.Unshipped.txt is untouched. The public-API analyzer confirms it -- no RS warnings. Only two call sites are on AngouriMath's side of the boundary and move: Content.Latexize() on an AngouriMath.Entity, and the ILatexizeable parameter in Interpret. One test expectation changes. 2.0 splits a radical over a positive factor, so 1+\sqrt{2x} expands to 1+\sqrt{2}\sqrt{x}. sqrt(2x) = sqrt(2)sqrt(x) holds for all complex x when the factored constant is positive, so the new output is sound; it is a rendering change rather than a correctness one. 955 of 955 tests pass. --- CSharpMath.Evaluation.Tests/InterpretTests.cs | 2 +- CSharpMath.Evaluation/CSharpMath.Evaluation.csproj | 2 +- CSharpMath.Evaluation/Evaluation.cs | 8 ++++++-- CSharpMath.Evaluation/Interpret.cs | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CSharpMath.Evaluation.Tests/InterpretTests.cs b/CSharpMath.Evaluation.Tests/InterpretTests.cs index f4675fce..a30bd493 100644 --- a/CSharpMath.Evaluation.Tests/InterpretTests.cs +++ b/CSharpMath.Evaluation.Tests/InterpretTests.cs @@ -10,7 +10,7 @@ public class InterpretTests { [InlineData(@"1+2", @"\underline\mathrm{Input}\\1+2\\\\\underline\mathrm{Simplified}\\3\\\\\underline\mathrm{Value\ (100\ digits)}\\3")] [InlineData(@"1+\sqrt", @"\color{red}\text{Missing radicand}")] [InlineData(@"1+\sqrt2", @"\underline\mathrm{Input}\\1+\sqrt{2}\\\\\underline\mathrm{Simplified}\\1+\sqrt{2}\\\\\underline\mathrm{Value\ (100\ digits)}\\2.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641573")] - [InlineData(@"1+\sqrt{2x}", @"\underline\mathrm{Input}\\1+\sqrt{2 x}\\\\\underline\mathrm{Simplified}\\1+\sqrt{2 x}\\\\\underline\mathrm{Expanded}\\1+\sqrt{2 x}\\\\\underline\mathrm{Factorized}\\1+\sqrt{2 x}")] + [InlineData(@"1+\sqrt{2x}", @"\underline\mathrm{Input}\\1+\sqrt{2 x}\\\\\underline\mathrm{Simplified}\\1+\sqrt{2 x}\\\\\underline\mathrm{Expanded}\\1+\sqrt{2} \sqrt{x}\\\\\underline\mathrm{Factorized}\\1+\sqrt{2 x}")] [InlineData(@"1+\sqrt{2xy}", @"\underline\mathrm{Input}\\1+\sqrt{2 x y}\\\\\underline\mathrm{Simplified}\\1+\sqrt{2 x y}\\\\\underline\mathrm{Expanded}\\1+\sqrt{2 x y}\\\\\underline\mathrm{Factorized}\\1+\sqrt{2 x y}")] [InlineData(@"=1+\sqrt{2xy}", @"\color{red}\text{Missing left side of equation}")] [InlineData(@"1+\sqrt{2xy}=", @"\color{red}\text{Missing right side of equation}")] diff --git a/CSharpMath.Evaluation/CSharpMath.Evaluation.csproj b/CSharpMath.Evaluation/CSharpMath.Evaluation.csproj index 942028b7..8f16b6e7 100644 --- a/CSharpMath.Evaluation/CSharpMath.Evaluation.csproj +++ b/CSharpMath.Evaluation/CSharpMath.Evaluation.csproj @@ -13,7 +13,7 @@ - + diff --git a/CSharpMath.Evaluation/Evaluation.cs b/CSharpMath.Evaluation/Evaluation.cs index ec6d1f16..58285cf1 100644 --- a/CSharpMath.Evaluation/Evaluation.cs +++ b/CSharpMath.Evaluation/Evaluation.cs @@ -42,16 +42,20 @@ enum Precedence { Postfix // Highest } - public abstract record MathItem : ILatexiseable { + public abstract record MathItem : ILatexizeable { private protected MathItem() { } public abstract string Latexise(); + // AngouriMath 2.0 renamed ILatexiseable.Latexise to ILatexizeable.Latexize. Implementing + // it explicitly keeps MathItem.Latexise as the public name here, so this package's own + // surface is unchanged by their rename. + string ILatexizeable.Latexize() => Latexise(); public static implicit operator MathItem(AngouriMath.Entity content) => new Entity(content); public static explicit operator AngouriMath.Entity(MathItem item) => ((Entity)item).Content; /// A real number, complex number, variable, function call, vector, matrix, higher-dimensional tensor, or set public sealed record Entity : MathItem { public Entity(AngouriMath.Entity content) => Content = content; public AngouriMath.Entity Content { get; } - public override string Latexise() => Content.Latexise(); + public override string Latexise() => Content.Latexize(); } /// A linked list of comma-delimited items public sealed record Comma : MathItem, IEnumerable { diff --git a/CSharpMath.Evaluation/Interpret.cs b/CSharpMath.Evaluation/Interpret.cs index 1f61f10d..8ad7bd15 100644 --- a/CSharpMath.Evaluation/Interpret.cs +++ b/CSharpMath.Evaluation/Interpret.cs @@ -3,8 +3,8 @@ namespace CSharpMath { static partial class Evaluation { - static StringBuilder AppendLaTeX(this StringBuilder sb, AngouriMath.Core.ILatexiseable latex) => - sb.Append(latex.Latexise()); + static StringBuilder AppendLaTeX(this StringBuilder sb, AngouriMath.Core.ILatexizeable latex) => + sb.Append(latex.Latexize()); static StringBuilder AppendLaTeXHeader(this StringBuilder sb, string header, bool includeNewlineBefore = true) { if (includeNewlineBefore) sb.Append(@"\\\\"); return sb.Append(@"\underline\mathrm{").Append(header).Append(@"}\\");