-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Champion: verbatim interpolated string (order of $@ vs. @$) (16.3, Core 3) #1630
Comments
I'd just vote for having a better error message from the compiler if you get this wrong. |
And a code fix in the IDE. 😄 |
I'll champion this. I think we should remove this little annoyance. 🦉 |
FWIW, this trips me up all the time. I basically just try one order, and if it doesn't work, i flip it. It's the USB-A connection of C#. |
@CyrusNajmabadi Except that this doesn't require 3 tries to get right. 🙃 |
I agree this is annoying, but I'm not sure if I like this being a preference/code style or just having this inconsistent everywhere. |
$@"..."
damn it! @$"..."
|
I'm really getting mixed signals here, substantive value? |
@Korporal, there is a significant difference between the two proposals. This one is a relaxation on an existing feature (recognizing both The other is an entirely new feature that impacts multiple things in the language (control flow, definite assignment, existing code using labels, etc) |
@tannergooding @CyrusNajmabadi - Sure I agree and think the ordering should be irrelevant but telling me in one thread that a change has to provide substantive value even if its simple to do and then endorsing something in this thread that clearly doesn't, seems like an inconsistent position. Just how many developers are asking for this? just how much pain does it cause developers? I'd be very surprised if this bothers developers more than poor support for exiting/continuing nested loops. |
There's clearly a zone for what account to niggles. i.e. they're not a new language feature per-se, they're just a tiny tweak of something already there. i.e. allowing separators in literals. Being more lenient with where "partial" can go. Allowing That's very different from an entirely new language concept. "i.e. a label on a loop that behaves differently if you 'goto' it or 'continue' it or 'break' it". These open actual design areas and introduce entirely new concepts to the language. That's an entirely different sort of thing. For things that really just affect hte lexing of a token, the bar is a lot lower. For things that introduce entirely new syntactic constructs that affect things as important as flow control, then there's goign to be a different bar. |
Almost every time I wanted to use |
AFAIK, there isn't some hardset rule of "weighing" a proposal, other than the general saying that everything starts at Two members of the language team could have different opinions on a proposal and one could choose to champion it, where the other may choose not to. Championing also doesn't necessarily mean it will get in, it just means that the champion will bring it forward at LDM because they think it is worthwhile. In this particular case, the proposal is for an existing feature, it is trivial to implement, and it is something that most C# devs who use the feature have probably hit when typing out code. As such, it is something that was deemed worthwhile almost immediately (because it is basically a bug fix). The other proposal is basically an entirely new feature, so it requires a lot more support, discussion, etc, to prove that it is worthwhile. |
Also, the messaging i gave was: It will be up to an LDM member to see if they want to champion. in this case, an LDM member is willing to champion the issue. :) |
Again I agree, my grumble is that you told me a proposed change "has to provide substantive value above and beyond just 'insufficiency'" yet here you're justifying this one based on implementation costs the very thing I tried to point out in the loop discussion. As I say I'm fine with this idea and I'd champion it too if I were in a position to but clearly substantive value is not as important as you implied. |
@Korporal, different people measure the "substance"/"impact" of a proposal differently 😄 |
More important than any of those factors, @gafter wants to champion it. That's a tall and subjective hurdle, and by no means guarantees that a proposal will go anywhere. This repo isn't a democracy. The C# language still firmly belongs to the language team at Microsoft. We get to watch the show and shout comments from the studio audience, but there's no commitment that it goes further than that. |
I didn't do any justification based on impl costs :) And i think you're conflating issues that appear as "little annoyances" to LDM members with issues that are more substantive in terms of design surface area and concept. These things are not the same, and are not really treated the same by many LDM members. |
You did when you wrote this in this response:
emphasis mine. This isn't really very important it just shows that different people here have different personal views of what matters and what doesn't which is only to be expected. But it does weaken your arguments about substantive value when it is pretty clear that adding a safer way to break or continue in nested loops (and thereby reduce the scope for badly behaving code) is more beneficial to users of the C# language than the ordering of these string tokens! |
That has nothing to do with impl cost. I'm saying, as a language feature, it's an incredibly tiny tweak. It's a niggle. It's on the scope of just impacting a single token the language has defined. This has nothing to do with the impl, it has to do with how many the language needs tweaking.
As i said above, the bars are different for different sorts of changes. I also made it clear over and over again that what was necessary was someone willing to champion the issue, and that all these proposals needed that. In a case like this, championing is easier because things are scoped so narrowly.
My argument was that you could get your "safer way to break or continue in nested loops" today just by writing an analyzer. INdeed, my overall argument would be: if you just want to to something you can already do today in C#, but you only want to restrict it, then analyzers are almost always the right way to things. As per the discussion in the other thread, you could already have such a feature yesterday if these efforts were spent on that. |
I hit that issue with verbatim string interpolation all the time. One would think that if order did not matter then I should only hit it 50% of the time , but no it is 100%. So I had to ask myself why? The answer is quite simple actually, and there are two reasons:
One has to wonder, why the opposite order was chosen in the first place... |
@Kryptos-FR Pre- or post-fix is a sensible default rather than infix when adding a new feature, tbh. |
That logic only holds if you read "verbatim string interpolation" as "verbatim (string interpolation)". |
Filed dotnet/roslyn#30012 for code style enforcement. |
Given that this feature needs to introduce a new code style for the ordering preference of @ and $ and that it introduces a point of inconsistency, I think I'd prefer a different solution. A code style for the ordering seems very strange since I don't think this is something most people care or have opinions about, they just want to get it right when typing. This code style would only exist to ensure consistency and would probably be turned on by default as a suggestion to use Essentially the experience as proposed for most people would be:
I propose a different approach. The language would still only support
|
TBH, that sounds very sensible to me. @jcouv what do you think? Might it be better to just make this a tooling-improvement story, instead of an actual language change? It woudl be similar to how i added support for -- In terms of fixing while typing. I'm normally a bit wary about that given the state-machine stuff you have to be careful with. (For example, if someone types |
I like @Neme12's proposal, especially the autocorrect without needing Ctrl+., because it's a step in a direction that I'd want regardless. If it turns out to still bug enough people who aren't using the VS IDE, the compiler can still be relaxed later on. |
I think that's workable, and it would indeed avoid style issues.
@CyrusNajmabadi Would you have a tip on how to do that? |
Literally just have a command handler that listens for type-chars. If you hear about $ go and look if it's right after @. If so, execute more complex logic to see if you should apply (i.e. you're not in a string), then just make the edit to the buffer :) |
Note: the only part i'm a little on the fence for is: Do we need a separate SyntaxKind for this. I can see arguments both ways... I'm leaning toward not wanting a new kind here, and having this just be something you can get for the regular kind... |
@jcouv do you mind if I try to implement this or would you like to do this yourself? |
The parser change was already merged with a single syntax kind |
I'm starting a thread with LDM to confirm we're ok to revert the language design (disallow @$ after all). @Neme12 That'd be great. I assume you'd take care of the compiler change too (always produce a diagnostic, regardless of LangVersion). We'll also want to delete the code fixer (made obsolete by new auto-fixer). |
The feedback from LDM is to keep the language feature (allow @$) because some editors won't have the auto-fixer. We can still implement a code style or auto-fixer in VS to improve style consistency. |
Ok, thanks |
Great. I think i prefer it that way. |
The answer of the question "is it shift-4-2 produces $@. |
How would @$ be parsed in Razor? In Razor, @ roughly defines the beginning of a code block. I've never tried it before, but it seems like Just some thoughts that popped into my head. I ain't no eckspurt. |
@alexdresko How would |
Tagging @rynowak as FYI, as new syntax could impact Razor. |
Thanks, making a note of it. |
Now the inconsistency in a team situation is going to drive people mad instead 😆 Resharper solves this by immediately correcting a mistake as you type. |
Visual Studio immediately corrects as you type, too. |
This proposal will extend object initializers to allow
@$"hello"
as a verbatim interpolated string, compared to$@"hello"
(current interpolated verbatim string).LDM history:
Would it be possible for the order of the string interpolation and string literal identifiers to not matter?
e.g.
var foo = $@"c:\foo\{someFile}";
Is fine, but
var foo = @$"c:\foo\{someFile}";
isn't...
There's probably a good reason for it that I'm missing, but would it be possible to make the order not matter?
O/T And looking at the title, I now realise$@ v @$ looks a bit like some funky owl, which I'm pleased with.
The text was updated successfully, but these errors were encountered: