-
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
C# PROPOSAL: Add more options to escape from string template #890
Comments
I just found some similar issues: |
Use of the razor syntax was suggested during the initial design of string interpolation and rejected. The interpolation syntax is a part of the C# language specification, the likelihood of a second syntax being considered alongside it is exceptionally low, especially since this proposal adds nothing new to the functionality. |
Don't you think it look cleaner when it was used in those use cases? |
Minimally, and I don't think that justifies adding a second interpolation grammar to the language specification. The current syntax was intentionally chosen to follow the conventions of |
Why do you think that second interpolation grammar |
since in C#, you can have many options to do the same thing. |
Because it represents a massive amount of work for virtually no gain. Things aren't added to the language just because they can be. |
since the first one may not suite in some situation (like in those use cases). and tool (IDE) designers have more options when |
Interpolation suits those use cases just fine. You are going to have to escape the curly braces, just like you would with As for tools, that exists outside of the language and can be implemented by analyzers today. To C# interpolated strings are just strings and nothing more. It knows nothing about JSON, CSS, HTML, SQL, etc., nor does it care anything about them. |
Yes, you are right. I will handle the content of it with the analyzer. But from the side of analyzer-tool developer. I think the code that look more concise/ readable/maintenance is one of |
Thank you for your comments. I'm late for string interpolation design discussion. so please think that I'm your student. |
Do you have a link or So I can learn what the team think and discuss about it |
String interpolation was designed while Roslyn was still over on CodePlex. Razor was brought up as an alternate syntax to the various proposals a couple of times. |
I will study that discussions. I think all Roslyn-Team have considered/discuss this before. Thank you for your comments and information. |
C# PROPOSAL: Add more options to escape from string template
VS2017,
Current Status :
with C#7 local function,
I can use it as a string template for external lang.
eg.
and this is the simple result ...
or json text
and the result...
What I want to PROPOSE:
"Add more option to escape from string template"
Currently, It may be specific after $
eg Razor style, $@@""
cs-parse found $ and follow by @@
cs-parse should escape when it found @ in the string literal
as if it found { } in C#7 , (see Razor as example)
(and more)
eg. Json
currently
other algorithms of string template should remain the same.
I think it would be useful in many aspects.
eg
the IDE can escape from the C# parsing context
and go to another proper parsing context (eg xml, json , css etc..)
If the IDE is not support (3rd party) context lang => the context lang is just string template.
But for IDE that support context lang (eg. via plug-in)=>
When you click on code in that context -> IDE move you to the context lang enviroment.
Hope you consider this,
or suggest me if you have other ways
Thank you
The text was updated successfully, but these errors were encountered: