{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/9407","repository_url":"https://api.github.com/repos/dotnet/roslyn","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/9407/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/9407/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/9407/events","html_url":"https://github.com/dotnet/roslyn/issues/9407","id":137936197,"number":9407,"title":"[Bug] Interpolated strings in attributes","user":{"login":"p-e-timoshenko","id":5479740,"avatar_url":"https://avatars.githubusercontent.com/u/5479740?v=3","gravatar_id":"","url":"https://api.github.com/users/p-e-timoshenko","html_url":"https://github.com/p-e-timoshenko","followers_url":"https://api.github.com/users/p-e-timoshenko/followers","following_url":"https://api.github.com/users/p-e-timoshenko/following{/other_user}","gists_url":"https://api.github.com/users/p-e-timoshenko/gists{/gist_id}","starred_url":"https://api.github.com/users/p-e-timoshenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/p-e-timoshenko/subscriptions","organizations_url":"https://api.github.com/users/p-e-timoshenko/orgs","repos_url":"https://api.github.com/users/p-e-timoshenko/repos","events_url":"https://api.github.com/users/p-e-timoshenko/events{/privacy}","received_events_url":"https://api.github.com/users/p-e-timoshenko/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-Language%20Design","name":"Area-Language Design","color":"5319e7"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Resolution-By%20Design","name":"Resolution-By Design","color":"cccccc"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":22,"created_at":"2016-03-02T17:19:35Z","updated_at":"2016-03-05T13:57:03Z","closed_at":"2016-03-04T20:59:16Z","body":"**Version Used**: CS 6\r\n\r\n**Steps to Reproduce**:\r\n```C#\r\n    class SomeClass\r\n    {\r\n        public const String FirstNameDef = \"Pavel\";\r\n\r\n        [Required(ErrorMessage = \"Field 'FirstName' is required.\")]\r\n\r\n        [Required(ErrorMessage = $\"Field {nameof(FirstName)} is required.\")] \r\n        // Error: An attribute argument must be a constant expression, \r\n        // typeof expression or array creation expression of an attribute parameter type\r\n\r\n        [DefaultValue(FirstNameDef)]\r\n        \r\n        [DefaultValue($\"{FirstNameDef}\")]  \r\n        // Error: An attribute argument must be a constant expression, \r\n        // typeof expression or array creation expression of an attribute parameter type\r\n\r\n        public String FirstName {\r\n            get { return _firstName; }\r\n            set { _firstName = value; }\r\n        }\r\n\r\n        public String _firstName = $\"{FirstNameDef}\";\r\n    }\r\n```"},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/192649964","html_url":"https://github.com/dotnet/roslyn/issues/9407#issuecomment-192649964","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/9407","id":192649964,"user":{"login":"p-e-timoshenko","id":5479740,"avatar_url":"https://avatars.githubusercontent.com/u/5479740?v=3","gravatar_id":"","url":"https://api.github.com/users/p-e-timoshenko","html_url":"https://github.com/p-e-timoshenko","followers_url":"https://api.github.com/users/p-e-timoshenko/followers","following_url":"https://api.github.com/users/p-e-timoshenko/following{/other_user}","gists_url":"https://api.github.com/users/p-e-timoshenko/gists{/gist_id}","starred_url":"https://api.github.com/users/p-e-timoshenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/p-e-timoshenko/subscriptions","organizations_url":"https://api.github.com/users/p-e-timoshenko/orgs","repos_url":"https://api.github.com/users/p-e-timoshenko/repos","events_url":"https://api.github.com/users/p-e-timoshenko/events{/privacy}","received_events_url":"https://api.github.com/users/p-e-timoshenko/received_events","type":"User","site_admin":false},"created_at":"2016-03-05T13:57:03Z","updated_at":"2016-03-05T13:57:03Z","body":"@tannergooding \r\n\"\" - in the beginning there were ordinary string,\r\n$\"\", $$\"\", $$$\"\", ... )\r\n\r\n@AdamSpeight2008 \r\n\"The idea of this preprocessor directive is to enforce the culture that is to be used be default.\"\r\nOnce more, It would be grateful to add such useful C++ preprocessor directive as following:\r\n#define MACRO_NAME ...\r\nBy the way, the C ++ language flew up for the last time and has surpassed C# (http://www.tiobe.com/tiobe_index)!\r\nI consider that it's desirable to avoid groving of amount of preprocessor directives.\r\nThe directives like bull in a china shop.\r\n\r\nThe ordinal strings is defined by quotes - \"\". The backslash means special character named escape sequence (https://msdn.microsoft.com/library/h21280bw(v=vs.110).aspx).\r\nAlso there is s string @\"\" that supressed escape sequence.\r\nSince C#6 there is string interpolation - $\"\". It is similar the syntax sugar of System.String.Format method. It's a good idea. But the using of dollar sign isn't very well. \r\n```C#\r\nString.Format($\"{0}\", 1); // Output: 0\r\nString.Format($\"{{0}}\", 1); // Output: 1\r\nString.Format($\"{{{{0}}}}\", 1); // Output: {0}\r\n```\r\nLet's see what will be if the dollar sign is absent.\r\n```C#\r\n\"...\" // ordinary string\r\n// After compilation: \"...\" \r\n\r\n\"...\\n\\t...\" // ordinary string with escape characters\r\n// After compilation: \"...\\n\\t...\"\r\n\r\n\"...\\#...\" // Error: Unrecoginzed escape sequence\r\n// In C ++ the hash symbol associated with preprocessor directives.\r\n// Therefore, it can be added to strings as string preprocessor directives.\r\n// \\#simple-string-preprocessor-directive# or \\#string-preprocessor-directive-with_argument{}\r\n// RegEx: \\\\#([A-Za-z][A-Za-z0-9-_]*(?=#|{|[^A-Za-z0-9-_]))#?(\\{([^{}]|(?R))*\\})?\r\n\r\n\" The property name is '\\#nameof{PropertyName}'.\"\r\n// After compilation: \" The property name is 'PropertyName'.\"\r\n// Older versions of .NET will generate an error: Unrecoginzed escape sequence\r\n\r\n\" The property value is '\\#eval{1f/2f + 1f/3f}'.\"\r\n// After compilation: \" The property value is '0.8333333'.\"\r\n\r\n\"\\#culture{ru-RU} The property value is '\\#eval{1f/2f + 1f/3f}'.\"\r\n// After compilation: \" The property value is '0,8333333'.\"\r\n\r\n\"The property value is '\\#culture{ru-RU}\\#eval{1f/2f + 1f/3f}'.\"\r\n// After compilation: \" The property value is '0,8333333'.\"\r\n// the directive \"culture\" affects to the next directive only if it is written in succession \\#dir1\\#dir2\r\n// The directive \"eval\" tries to convert to string at compile time.\r\n// What couldn't be converted, it makes the argument of String.Format\r\n\r\n\"The property value is '\\#culture{ru-RU}\\#eval{1f/2f + 1f/3f  + someVar}'.\"\r\n// After compilation: String.Format(\" The property value is '{0}'.\", (1f/2f + 1f/3f  + someVar).ToString(new CultureInfo(\"ru-RU\")))\r\n\r\n// You can forcibly to make value as a parameter of String.Format:\r\n\"The property value is '\\#culture{ru-RU}\\#insert{1f/2f + 1f/3f + someConst}'.\"\r\n// After compilation: String.Format(\" The property value is '{0}'.\", (1f/2f + 1f/3f + someConst).ToString(new CultureInfo(\"ru-RU\")))\r\n\r\n\"The algebraic expression '\\#codeof{0.5f + 1f/3f}' equals '\\#culture{ru-RU}\\#eval{1f/2f + 1f/3f}'.\"\r\n// After compilation: \" The algebraic expression '0.5f + 1f/3f' equals '0,8333333'.\"\r\n```\r\n\r\n\r\n"}}