93 Replies
why is this adding so many tabs!?
it makes no since. this is super simple but broken
the new line somehow adds space chars equal to the number of chars before the line break
smells like a bug
what do you mean?
cannot reproduce that
yea
i am soo screwed
is that rider? maybe there's a setting for newline
possible. will check that out
that looks a lot like that the console (the tab, not the class) expects a
\r\n
but Console.WriteLine()
only writes a \n
for some reason.
\r
= CR = Carriage Return, moves the cursor back to the line start (as in x = 0, if u will)
\n
= NL = New Line, move to the next line (as in y + 1, if u will)
if u execute it from terminal/console outside of the IDE, does it work there as expected?The "some reason" is that their string contains "\n" -- they're only calling
Console.WriteLine
once
And seconded, this is exactly the output when you send "\n", but the terminal doesn't add an implicit "\r" with every "\n"oh right
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
TeBeCo
REPL Result: Success
Console Output
Compile: 480.701ms | Execution: 30.757ms | React with β to remove this embed.
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
TeBeCo
REPL Result: Success
Console Output
Compile: 506.782ms | Execution: 30.704ms | React with β to remove this embed.
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
TeBeCo
REPL Result: Success
Console Output
Compile: 483.969ms | Execution: 30.941ms | React with β to remove this embed.
im cant find it, which line break does that multi line string literal use?
the one from the source code, depends on how u compile or runtime dependent?
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
so there is no clear answer to that D:
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
seems easy to check
the line break is included and encoded as CRLF in the string literal
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
defaultInterpolatedStringHandler.AppendLiteral("\r\nredThresholdWidth == ");
there is encoded as CRLF, and i doubt any magic happens under the hood to normalize the literal.
thus it seems more likely that its source dependentUnknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
oh sorry, should have mentioned that
but it might not be true, i expected that sharplab runs on a linux container
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
but its windows
Microsoft Windows NT 10.0.17763.0
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
but in the end it would still be compile time and not runtime
so its either source dependent or compiler host platform dependent because its not using
Environment.NewLine
at all but the escape sequenceTeBeCo
REPL Result: Failure
Exception: CompilationErrorException
Compile: 457.638ms | Execution: 0.000ms | React with β to remove this embed.
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
modix is embedding that code weirldy
cap5lut
REPL Result: Success
Console Output
Compile: 409.472ms | Execution: 35.986ms | React with β to remove this embed.
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
Wat?
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
cap5lut
REPL Result: Success
Result: OperatingSystem
Compile: 221.486ms | Execution: 18.618ms | React with β to remove this embed.
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
What's OS dependent?
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
linebreak in multi line string literals
Doesn't it literally depend on whether your source file is saved with LF or CRLF?
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
not sure if discord normalizes the linebreaks somewhere tho
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
thats the question we have right now ;p
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
I'm pretty sure I read it an issue somewhere in dotnet/ a long time ago
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
https://github.com/dotnet/csharplang/discussions/8237 pops up from a quick search
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
IIRC there are unit tests in dotnet/runtime (or maybe /roslyn?) which are sensitive to the file line endings -- I saw that pop up recently
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
It was also raised in the proposal: https://github.com/dotnet/csharplang/issues/4304
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
Just tell git to checkout as LF?
.gitattributes:
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
What?
That line applies to all .cs files in your repo
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
for me its more the just-dont-use-raw-strings thingy here π
Why not checkout .cs files as LF across the board?
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
You should have things set up so that they're stored in git as LF anyway
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
Yeah, if you specifically need CR in a particular string literal, that's a pain
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
But that's a pain in languages which don't rely on the file's line endings like Python, as well
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
Yeah, it wasn't clear that that's what you meant, because you speak in half-sentences π
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
in ur local repo, even if u set it as EOL=LF, it wouldnt touch the source until u commit (or later) right?
so if u locally work with an IDE that write CRLF everything works fine, all tests run fine and then after committing (and maybe more) it would explode?
i .... think we should move this discussion out of this thread by now π
If they were previously CRLF, then you added that .gitattributes, you'd need
git add --renormalize
to change the actual filesdo IDEs read/analyze/respect these settings if u create a new cs file?
Not sure?
and thats the problem ;p
actually its not
It should get sorted the first time you
git add
maybe? Little fuzzy thereu would add the .editorconfig thingy to the repo as well, wouldnt u?
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
i never ever touched these myself so im a virgin there π
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
I've never had that not work
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
i think its also a bit about where that goes, nowadays a lot of terminals/text viewers/etc simply treat both a LF and CRLF as the "expected" line break right?
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
this is at the same time so weird but also understandable, i think i will never forget it π
8
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
Oh boy thatβs a lot of text
TeBeCo
REPL Result: Success
Console Output
Quoted by
<@689473681302224947> from #whats up with this console output (click here)
Compile: 506.782ms | Execution: 30.704ms | React with β to remove this embed.
Unknown Userβ’3mo ago
Message Not Public
Sign In & Join Server To View
If you have no further questions, please use /close to mark the forum thread as answered