Unbalanced curly braces - is this necessary?
mennodeij opened this issue · 1 comments
mennodeij commented
Hi! Great work on SmartFormat - exactly what I was looking for.
I have a question that relates to the underlying test example. To get the required format, I need unbalanced curly braces. That seems unlogical, but I could not find another way. Is this a feature, or is there a way to use balanced braces? Or is this a problem that needs to be fixed?
struct Vector3d
{
public double X;
public double Y;
public double Z;
public Vector3d(double x, double y, double z)
{
X = x;
Y = y;
Z = z;
}
}
[Test]
public void TestSimpleAndVectorFormat()
{
double a = 3.55, b = 8.996;
Vector3d v = new Vector3d(1.25, 2.55, 3.77);
string s = Smart.Format("{0:0.000}_{1:{X:0.000}_{Y:0.000}_{Z:0.000}+{2:0.000}", a, v, b);
Assert.AreEqual("3.550_1.250_2.550_3.770+8.996", s);
}
mennodeij commented
Note to self: RTFM
https://github.com/scottrippey/SmartFormat.NET/wiki/Common-Pitfalls
Solution : define a different escape character using Smart.Default.Parser.UseAlternativeEscapeChar('\');