protected override void AppendExpressionPart(string part) { // replace string.class => typeof(string), string.valueOf(x) => x.ToString(), etc part = GenericExpressionHelper.ConvertTypeofExpressionsToCSharp(part); part = GenericExpressionHelper.ConvertStringValueofToString(part); part = GenericExpressionHelper.ConvertApexInstanceOfTypeExpressionToCSharp(part); part = GenericExpressionHelper.ConvertApexTypesToCSharp(part); base.AppendExpressionPart(part); }
public void StringValueofSomethingIsConvertedToSomethingToString() { var text = "string.valueOf(1)"; var csharp = GenericExpressionHelper.ConvertStringValueofToString(text); Assert.AreEqual("1.ToString()", csharp); text = "string.valueOf(something)"; csharp = GenericExpressionHelper.ConvertStringValueofToString(text); Assert.AreEqual("something.ToString()", csharp); text = "string.valueOf(something+1)"; csharp = GenericExpressionHelper.ConvertStringValueofToString(text); Assert.AreEqual("(something+1).ToString()", csharp); // not supported by regex-based expression helper text = "string.valueOf(method())"; csharp = GenericExpressionHelper.ConvertStringValueofToString(text); Assert.AreEqual("string.valueOf(method())", csharp); }