{"action":"opened","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/19371","repository_url":"https://api.github.com/repos/dotnet/roslyn","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/19371/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/19371/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/19371/events","html_url":"https://github.com/dotnet/roslyn/issues/19371","id":227499214,"number":19371,"title":"API replacement for named arguments in IOperation","user":{"login":"bkoelman","id":10324372,"avatar_url":"https://avatars2.githubusercontent.com/u/10324372?v=3","gravatar_id":"","url":"https://api.github.com/users/bkoelman","html_url":"https://github.com/bkoelman","followers_url":"https://api.github.com/users/bkoelman/followers","following_url":"https://api.github.com/users/bkoelman/following{/other_user}","gists_url":"https://api.github.com/users/bkoelman/gists{/gist_id}","starred_url":"https://api.github.com/users/bkoelman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bkoelman/subscriptions","organizations_url":"https://api.github.com/users/bkoelman/orgs","repos_url":"https://api.github.com/users/bkoelman/repos","events_url":"https://api.github.com/users/bkoelman/events{/privacy}","received_events_url":"https://api.github.com/users/bkoelman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-05-09T21:11:03Z","updated_at":"2017-05-09T21:11:03Z","closed_at":null,"body":"**Version Used**: \r\nmaster branch\r\n\r\nAs discussed in https://github.com/dotnet/roslyn/issues/8813:\r\n\r\n> It is not obvious what value do we get from distinguishing between Positional and Named arguments. I believe Analyzers will be more interested in the order, in which arguments are evaluated (ArgumentsInEvaluationOrder solves that). Knowing whether the argument was named doesn't look that important and can always be discovered from syntax.\r\n\r\nBecause I have an [existing analyzer](https://github.com/bkoelman/CSharpGuidelinesAnalyzer/blob/master/src/CSharpGuidelinesAnalyzer/CSharpGuidelinesAnalyzer/Rules/Maintainability/AvoidUsingNamedArgumentsAnalyzer.cs) that depends on `ArgumentKind.Named`, I tried to use syntax instead. However I failed to get that working.\r\n\r\nPlease consider the next program:\r\n```csharp\r\nusing System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing Microsoft.CodeAnalysis;\r\nusing Microsoft.CodeAnalysis.CSharp;\r\nusing Microsoft.CodeAnalysis.CSharp.Syntax;\r\nusing Microsoft.CodeAnalysis.Semantics;\r\n\r\nnamespace ConsoleApp2\r\n{\r\n    class Program\r\n    {\r\n        static void Main(string[] args)\r\n        {\r\n            const string source = @\"\r\n                class C\r\n                {\r\n                    void M(int i, string s = null)\r\n                    {\r\n                    }\r\n\r\n                    void N()\r\n                    {\r\n                        M(3, s: string.Empty);\r\n                    }\r\n                }\";\r\n\r\n            Document document = new AdhocWorkspace()\r\n                .AddProject(\"TestProject\", LanguageNames.CSharp)\r\n                .AddMetadataReferences(new[]\r\n                {\r\n                    MetadataReference.CreateFromFile(typeof(object).Assembly.Location),\r\n                    MetadataReference.CreateFromFile(typeof(ValueTuple).Assembly.Location),\r\n                    MetadataReference.CreateFromFile(typeof(System.IO.FileSystemInfo).Assembly.Location),\r\n                    MetadataReference.CreateFromFile(typeof(System.Reflection.Metadata.ArrayShape).Assembly.Location)\r\n                })\r\n                .WithCompilationOptions(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary))\r\n                .AddDocument(\"Source.cs\", source)\r\n                .Project\r\n                .WithParseOptions(new CSharpParseOptions().WithFeatures(new[]\r\n                {\r\n                    new KeyValuePair<string, string>(\"IOperation\", \"true\")\r\n                }))\r\n                .Documents.First();\r\n\r\n            SemanticModel model = document.GetSemanticModelAsync().Result;\r\n\r\n            if (model.Compilation.GetDiagnostics().Any())\r\n            {\r\n                throw new Exception(string.Join(Environment.NewLine, model.Compilation.GetDiagnostics()));\r\n            }\r\n\r\n            var typeSymbol = model.Compilation.GetTypeByMetadataName(\"C\");\r\n            var methodSymbol = typeSymbol.GetMembers(\"N\").OfType<IMethodSymbol>().Single();\r\n            var methodSyntax = (MethodDeclarationSyntax) methodSymbol.DeclaringSyntaxReferences.First().GetSyntax();\r\n\r\n            var bodyOperation = (IBlockStatement) model.GetOperation(methodSyntax.Body);\r\n            var statement = (IExpressionStatement) bodyOperation.Statements.First();\r\n            var invocation = (IInvocationExpression) statement.Expression;\r\n            var arg0 = (IArgument) invocation.ArgumentsInEvaluationOrder.First();\r\n            var arg1 = (IArgument) invocation.ArgumentsInEvaluationOrder.Skip(1).First();\r\n\r\n            var syn0 = (LiteralExpressionSyntax) arg0.Syntax;\r\n            var syn1 = (MemberAccessExpressionSyntax) arg1.Syntax;\r\n\r\n            Console.WriteLine(\"0: \" + syn0.ToFullString());\r\n            Console.WriteLine(\"1: \" + syn1.ToFullString());\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nwhich prints:\r\n```\r\n0: 3\r\n1: string.Empty\r\n```\r\n\r\nWhat would be the correct way to determine if an argument is named? If non-trivial, it would be helpful to me when I would use a boolean property `IArgument.IsNamed`."}}
{"actor":{"display_login":"bkoelman"}}