Some extra info: http://www.informit.com/articles/article.aspx?p=2422807
And you need it too for complete C# compatibility.
Some extra info: http://www.informit.com/articles/article.aspx?p=2422807
And you need it too for complete C# compatibility.
Carlo, question: is the editor handling the problem or the compiler implementation?
Editor handling isn’t a big problem, just a bug. Nesting however is a big issue in the compiler, one that’s fairly hard to solve with the approach I took.
Trying to help.
Do you have, somewhere in the compile process, the interpolated string in raw form like this:
$“embedded interpolated string: {if item2=“123” then $“here is {item1}” else $”{item2}“} and some more text”
If so, call his function to change the code (preprocessor) - then you have NO interpolated strings to worry about; it de-interpolates the string to a normal concatenated string:
method DeInterpolateStrings(InterpolatedString: String): String;
begin
//InterpolatedString is the complete string, including embedded fields and other (interpolated) strings
//by example: $"embedded interpolated string: {if item2="123" then $"here is {item1}" else $"{item2}"} and some more text"
//Deinterpolates the string, including embedded inerpolted strings to:
//"embedded interpolated string: " + (if item2="123" then "here is " + (item1) else (item2)) + " and some more text"
result := "";
var SkipNext: Boolean := false;
for i: Integer := 0 to InterpolatedString.Length - 1 do
begin
if not SkipNext then
begin
if i < InterpolatedString.Length - 2 then
begin
if InterpolatedString.Substring(i,2) = '$"' then
begin
continue //for i;
end;
if InterpolatedString.Substring(i,2) = '"{' then
begin
result := result + '(';
SkipNext := true;
continue //for i;
end;
if InterpolatedString.Substring(i,2) = '}"' then
begin
result := result + ')';
SkipNext := true;
continue //for i;
end;
end;
if InterpolatedString[i] = '{' then
begin
result := result + '" + (';
continue //for i;
end;
if InterpolatedString[i] = '}' then
begin
result := result + ') + "';
continue //for i;
end;
result := result + InterpolatedString[i];
end
else
SkipNext := false;
end;
end;
bugs://80650 got closed with status fixed.
@Theo69 that’s not really the problem, currently the tokenizer (which has to switch in and out of strings) can’t easily maintain the level at which it’s current at, which is needed by the parser at a later point. It can be added but needs some thought for how to do that exactly.
Exactly. Even more so, for the syntax highlighter, I need to be a able to start highlighting at any given line (not from the start of a file), with a limited set of metadata abut the current state at the start of that line. Arbitrary nesting of strings & code makes that very tricky.
Can I get an internal water build for this fix?
yes but I wanted to check if the obfuscation works first before I upload it.
I am stuck because of the errors in the editor caused by the string interpolation.
Next release on monday, so I can use the official build for the obfuscation.
a new build should be up on your personal downloads page.
Downloading it now - thanks.
The fix did not help …
Wont work:
My.Computer.FileSystem.WriteAllText(My.Settings.PaysafeLogFile,
$"{Now.ToShortDateString} {Now.ToLongTimeString} - RECONCILIATION: GET FILES FROM SERVER"#1310,
True);
Works:
My.Computer.FileSystem.WriteAllText(My.Settings.PaysafeLogFile,
Now.ToShortDateString + " " + Now.ToLongTimeString + " - RECONCILIATION: GET FILES FROM SERVER"#1310,
True);
bugs://80650 got reopened.
Extra info:
Single quote interpolated strings work, double quote not - even if it is on one line.
Edit: the above does also not work with single quotes.
Hello Theo,
Could you please give me a video on what exactly is wrong with single quotes? For now I only found one problem - when typing something right after " item, the highglighting breaks. I fixed that. What else is failing for you with single quotes?
The double quotes are not supported yet, not in compiler, not in highlighter.
Thanks in advance.
Hereby: