{"action":"created","issue":{"url":"https://api.github.com/repos/icsharpcode/CodeConverter/issues/61","repository_url":"https://api.github.com/repos/icsharpcode/CodeConverter","labels_url":"https://api.github.com/repos/icsharpcode/CodeConverter/issues/61/labels{/name}","comments_url":"https://api.github.com/repos/icsharpcode/CodeConverter/issues/61/comments","events_url":"https://api.github.com/repos/icsharpcode/CodeConverter/issues/61/events","html_url":"https://github.com/icsharpcode/CodeConverter/issues/61","id":306806681,"number":61,"title":"C# -> VB: Support Throw Expressions","user":{"login":"GrahamTheCoder","id":2490482,"avatar_url":"https://avatars1.githubusercontent.com/u/2490482?v=4","gravatar_id":"","url":"https://api.github.com/users/GrahamTheCoder","html_url":"https://github.com/GrahamTheCoder","followers_url":"https://api.github.com/users/GrahamTheCoder/followers","following_url":"https://api.github.com/users/GrahamTheCoder/following{/other_user}","gists_url":"https://api.github.com/users/GrahamTheCoder/gists{/gist_id}","starred_url":"https://api.github.com/users/GrahamTheCoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GrahamTheCoder/subscriptions","organizations_url":"https://api.github.com/users/GrahamTheCoder/orgs","repos_url":"https://api.github.com/users/GrahamTheCoder/repos","events_url":"https://api.github.com/users/GrahamTheCoder/events{/privacy}","received_events_url":"https://api.github.com/users/GrahamTheCoder/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"GrahamTheCoder","id":2490482,"avatar_url":"https://avatars1.githubusercontent.com/u/2490482?v=4","gravatar_id":"","url":"https://api.github.com/users/GrahamTheCoder","html_url":"https://github.com/GrahamTheCoder","followers_url":"https://api.github.com/users/GrahamTheCoder/followers","following_url":"https://api.github.com/users/GrahamTheCoder/following{/other_user}","gists_url":"https://api.github.com/users/GrahamTheCoder/gists{/gist_id}","starred_url":"https://api.github.com/users/GrahamTheCoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GrahamTheCoder/subscriptions","organizations_url":"https://api.github.com/users/GrahamTheCoder/orgs","repos_url":"https://api.github.com/users/GrahamTheCoder/repos","events_url":"https://api.github.com/users/GrahamTheCoder/events{/privacy}","received_events_url":"https://api.github.com/users/GrahamTheCoder/received_events","type":"User","site_admin":false},"assignees":[{"login":"GrahamTheCoder","id":2490482,"avatar_url":"https://avatars1.githubusercontent.com/u/2490482?v=4","gravatar_id":"","url":"https://api.github.com/users/GrahamTheCoder","html_url":"https://github.com/GrahamTheCoder","followers_url":"https://api.github.com/users/GrahamTheCoder/followers","following_url":"https://api.github.com/users/GrahamTheCoder/following{/other_user}","gists_url":"https://api.github.com/users/GrahamTheCoder/gists{/gist_id}","starred_url":"https://api.github.com/users/GrahamTheCoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GrahamTheCoder/subscriptions","organizations_url":"https://api.github.com/users/GrahamTheCoder/orgs","repos_url":"https://api.github.com/users/GrahamTheCoder/repos","events_url":"https://api.github.com/users/GrahamTheCoder/events{/privacy}","received_events_url":"https://api.github.com/users/GrahamTheCoder/received_events","type":"User","site_admin":false}],"milestone":null,"comments":5,"created_at":"2018-03-20T10:27:53Z","updated_at":"2018-03-28T04:46:46Z","closed_at":"2018-03-26T20:54:34Z","author_association":"CONTRIBUTOR","body":"```\r\n  Error processing Vsix\\ConvertCSToVBCommand.cs\r\n    In 'C:\\Users\\Graham\\Documents\\GitHub\\CodeConverter\\Vsix\\ConvertCSToVBCommand.cs':\r\n    System.NotImplementedException: Cannot convert ThrowExpressionSyntax from 'throw new ArgumentNullExcep...' at character 2446\r\n     in 'package ?? '\r\n       at ICSharpCode.CodeConverter.VB.CSharpConverter.MethodBodyVisitor.DefaultVisit(SyntaxNode node)\r\n       at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor`1.VisitThrowExpression(ThrowExpressionSyntax node)\r\n       at Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax.Accept[TResult](CSharpSyntaxVisitor`1 visitor)\r\n       at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor`1.Visit(SyntaxNode node)\r\n       at ICSharpCode.CodeConverter.VB.CommentConvertingMethodBodyVisitor.DefaultVisit(SyntaxNode node)\r\n       at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor`1.VisitThrowExpression(ThrowExpressionSyntax node)\r\n       at Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax.Accept[TResult](CSharpSyntaxVisitor`1 visitor)\r\n       at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor`1.Visit(SyntaxNode node)\r\n       at ICSharpCode.CodeConverter.VB.CSharpConverter.NodesVisitor.DefaultVisit(SyntaxNode node)\r\n       at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor`1.VisitThrowExpression(ThrowExpressionSyntax node)\r\n       at Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax.Accept[TResult](CSharpSyntaxVisitor`1 visitor)\r\n       at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor`1.Visit(SyntaxNode node)\r\n       at ICSharpCode.CodeConverter.VB.CommentConvertingNodesVisitor.DefaultVisit(SyntaxNode node)\r\n       ...\r\n```\r\n\r\n### Option 1\r\nAdd a ThrowEx method that's something like\r\n``` \r\nPrivate Shared Function ThrowEx(Of T)(ByVal e As Exception) As T\r\n    Throw e\r\nEnd Function\r\n```\r\nCalling code\r\n```\r\nThrowEx(Of Integer)(New Exception)\r\n```\r\nThen just replace the throw expression with a call to that. The generic is so that the rest of the expression can get the right type. It's a bit messy, and needs to add a method which is awkward for snipped conversions, but does keep the code pretty readable in the context it was written.\r\n\r\n### Option 2\r\nDefine a function outside the block, then use it where the original throw would have been\r\n\r\n```\r\n        Dim throwEx As Func(Of Integer) = \r\n                Function()\r\n            Throw New Exception\r\n        End Function\r\n        Dim asd = IIf(True, 9, throwEx())\r\n```\r\n\r\nThis avoids having to add an extra method at the class level (which means sub-method snippets will convert less cleanly), at the expense of more code for each time this is used.\r\n\r\n### Proposal\r\nOption 1. We can always implement option 2 as a special case if someone's particularly enthusiastic about it.\r\n"},"comment":{"url":"https://api.github.com/repos/icsharpcode/CodeConverter/issues/comments/376760096","html_url":"https://github.com/icsharpcode/CodeConverter/issues/61#issuecomment-376760096","issue_url":"https://api.github.com/repos/icsharpcode/CodeConverter/issues/61","id":376760096,"user":{"login":"RussellSmith2","id":37516277,"avatar_url":"https://avatars2.githubusercontent.com/u/37516277?v=4","gravatar_id":"","url":"https://api.github.com/users/RussellSmith2","html_url":"https://github.com/RussellSmith2","followers_url":"https://api.github.com/users/RussellSmith2/followers","following_url":"https://api.github.com/users/RussellSmith2/following{/other_user}","gists_url":"https://api.github.com/users/RussellSmith2/gists{/gist_id}","starred_url":"https://api.github.com/users/RussellSmith2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RussellSmith2/subscriptions","organizations_url":"https://api.github.com/users/RussellSmith2/orgs","repos_url":"https://api.github.com/users/RussellSmith2/repos","events_url":"https://api.github.com/users/RussellSmith2/events{/privacy}","received_events_url":"https://api.github.com/users/RussellSmith2/received_events","type":"User","site_admin":false},"created_at":"2018-03-28T04:46:46Z","updated_at":"2018-03-28T04:46:46Z","author_association":"NONE","body":"\"_\" not a valid parameter name was just 1 issue found after converting ConvertQueryBodyClause method in CSharp\\NodesVisitor.cs to VB.\r\n\r\nThe CSharpImpl.__Throw(Of System.Func`2 code is the throwing the following error.\r\nArgument not specified for parameter 'e' of ' Public Shared Function __Throw(Of System.Func)(e As Exception) As System.Func'\r\n\r\nAll but the first parameter that is preceded by AddressOf is also throwing an error.  It appears it is an overload resolution error.  The correct VB code I listed yesterday does not throw any errors.\r\n\r\n"}}
{"actor":{"display_login":"RussellSmith2"}}