{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/2239","repository_url":"https://api.github.com/repos/dotnet/roslyn","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/2239/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/2239/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/2239/events","html_url":"https://github.com/dotnet/roslyn/issues/2239","id":70742789,"number":2239,"title":"[Proposal]: Support \"raw\" string literals","user":{"login":"HaloFour","id":10102290,"avatar_url":"https://avatars1.githubusercontent.com/u/10102290?v=4","gravatar_id":"","url":"https://api.github.com/users/HaloFour","html_url":"https://github.com/HaloFour","followers_url":"https://api.github.com/users/HaloFour/followers","following_url":"https://api.github.com/users/HaloFour/following{/other_user}","gists_url":"https://api.github.com/users/HaloFour/gists{/gist_id}","starred_url":"https://api.github.com/users/HaloFour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HaloFour/subscriptions","organizations_url":"https://api.github.com/users/HaloFour/orgs","repos_url":"https://api.github.com/users/HaloFour/repos","events_url":"https://api.github.com/users/HaloFour/events{/privacy}","received_events_url":"https://api.github.com/users/HaloFour/received_events","type":"User","site_admin":false},"labels":[{"id":169838071,"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-Language%20Design","name":"Area-Language Design","color":"5319e7","default":false},{"id":166672105,"url":"https://api.github.com/repos/dotnet/roslyn/labels/Discussion","name":"Discussion","color":"fbca04","default":false},{"id":166677091,"url":"https://api.github.com/repos/dotnet/roslyn/labels/Feature%20Request","name":"Feature Request","color":"e52727","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":24,"created_at":"2015-04-24T17:17:33Z","updated_at":"2018-04-07T21:34:26Z","closed_at":null,"author_association":"NONE","body":"## Problem:\n\nVerbatim string literals are often used to copy in chunks of text such as SQL or XML.  It's not uncommon for this text to contain embedded double-quotes, which then must be doubled-up in C# in order to be escaped.  This makes it obnoxious if you have to copy and paste the text back and forth since it would have to be fixed each time.\n\n``` cs\nstring xml = @\"<?xml version=\"\"1.0\"\"?>\n<root>\n    <item attr=\"\"foo\"\" />\n</root>\";\n```\n## Solution:\n\nBy supporting a custom notation for starting and ending a string literal it enables evaluating the double quotes as part of the string that do not have to be escaped.  The programmer would use a pattern at the beginning of the string which then must be matched to denote the end of the string.\n\nProposed syntax would be based on verbatim string syntax:\n\n_raw-string-literal_:\n    @(\"   _raw-string-literal-characters_ <sup>opt</sup>   \" )\n    @( _identifier_ \"   _raw-string-literal-characters_ <sup>opt</sup>   \" _identifier_ )\n\n_raw-string-literal-characters_:\n    Any characters except \" _identifer_ <sup>opt</sup> )\n\nThe `@` would be immediately followed by an open-parenthesis (`(`).  Following that is an optional delimiter which is any legal C# identifier and then a double-quote.  Next would be the raw string contents which would be interpreted exactly as they appear in the file.  The terminator of the string literal would be a double quote immediately followed by the optional delimiter and a close-parenthesis (`)`).\n\nThe following example is a raw string without a custom delimiter.  It is terminated simply by the sequence `\")`.  Double quotes that appear within the string are interpreted as a part of the string as long as they are not followed by a close-parenthesis character (`)`).\n\n``` cs\nstring xml = @(\"<?xml version=\"1.0\"?>\n<root>\n    <item attr=\"foo\" />\n</root>\");\n```\n\nThe following example is a raw string with a custom delimiter.  As the custom delimiter is specified as \"foo\" that sets the terminating sequence to be `\"foo)`.  Any other characters are interpreted as a part of the string literal, including any portion of the terminating sequence.  Note that the term \"foo\" appears within the string after a double-quote, but since it is not also followed by a close-parenthesis (`)`) it is not considered the terminating sequence of the literal.\n\nIn this example the custom delimiter is \"foo\".  Note that the attribute value is not considered as the end of the string.  However, if it was followed by a parenthesis it would be and a different custom delimiter might have to be chosen.\n\n``` cs\nstring xml = @(foo\"<?xml version=\"1.0\"?>\n<root>\n    <item attr=\"foo\" />\n</root>\"foo);\n```\n\nHere are examples of raw strings containing the syntax for other raw strings:\n\n``` cs\nstring raw1 = @(foo\"string s = @(\"Hello!\");\"foo);\nstring raw2 = @(bar\"string raw1 = @(\"string s = @(\"Hello!\");\"foo);\"bar);\nstring raw3 = @(baz\"string raw2 = @(bar\"string raw1 = @(\"string s = @(\"Hello!\");\"foo);\"bar);\"baz);\n```\n\nThis syntax is loosely based on C++11 raw string literals, although I personally don't care for the parenthesis or delimiter appearing within the body of the string.  I'm definitely not married to this syntax and variations are welcome.\n\nExisting UserVoice suggestion, using C++11-like syntax:  [Allow to have custom delimiters in raw string literal](http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/5678481-allow-to-have-custom-delimiters-in-raw-string-lite)\n"},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/379500841","html_url":"https://github.com/dotnet/roslyn/issues/2239#issuecomment-379500841","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/2239","id":379500841,"user":{"login":"ericnewton76","id":2211788,"avatar_url":"https://avatars0.githubusercontent.com/u/2211788?v=4","gravatar_id":"","url":"https://api.github.com/users/ericnewton76","html_url":"https://github.com/ericnewton76","followers_url":"https://api.github.com/users/ericnewton76/followers","following_url":"https://api.github.com/users/ericnewton76/following{/other_user}","gists_url":"https://api.github.com/users/ericnewton76/gists{/gist_id}","starred_url":"https://api.github.com/users/ericnewton76/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericnewton76/subscriptions","organizations_url":"https://api.github.com/users/ericnewton76/orgs","repos_url":"https://api.github.com/users/ericnewton76/repos","events_url":"https://api.github.com/users/ericnewton76/events{/privacy}","received_events_url":"https://api.github.com/users/ericnewton76/received_events","type":"User","site_admin":false},"created_at":"2018-04-07T21:34:26Z","updated_at":"2018-04-07T21:34:26Z","author_association":"NONE","body":"@michael-hawker I can go with that... Python's triple quotes or Triple backtick or something... \r\n\r\nSomething is better than nothing.  C# only really supports ```@``` for string literals, and of course doesnt work with any html cut/pasted directly (when it has double quotes for attribute values)"}}
{"actor":{"display_login":"ericnewton76"}}