{"action":"created","issue":{"url":"https://api.github.com/repos/icsharpcode/ILSpy/issues/1115","repository_url":"https://api.github.com/repos/icsharpcode/ILSpy","labels_url":"https://api.github.com/repos/icsharpcode/ILSpy/issues/1115/labels{/name}","comments_url":"https://api.github.com/repos/icsharpcode/ILSpy/issues/1115/comments","events_url":"https://api.github.com/repos/icsharpcode/ILSpy/issues/1115/events","html_url":"https://github.com/icsharpcode/ILSpy/issues/1115","id":312321486,"number":1115,"title":"How to create a method body ? ","user":{"login":"na2axl","id":14062034,"avatar_url":"https://avatars0.githubusercontent.com/u/14062034?v=4","gravatar_id":"","url":"https://api.github.com/users/na2axl","html_url":"https://github.com/na2axl","followers_url":"https://api.github.com/users/na2axl/followers","following_url":"https://api.github.com/users/na2axl/following{/other_user}","gists_url":"https://api.github.com/users/na2axl/gists{/gist_id}","starred_url":"https://api.github.com/users/na2axl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/na2axl/subscriptions","organizations_url":"https://api.github.com/users/na2axl/orgs","repos_url":"https://api.github.com/users/na2axl/repos","events_url":"https://api.github.com/users/na2axl/events{/privacy}","received_events_url":"https://api.github.com/users/na2axl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-04-08T16:59:07Z","updated_at":"2018-04-08T19:48:20Z","closed_at":null,"author_association":"NONE","body":"I was using an old version of ICSharpCode.Decompiler for a while, but recently I've upgraded to the latest version from Nuget. There was several changes with the upgrade and I think I've fixed them but now I'm facing another one, how to create a method body?\r\nThe code I'm trying to upgrade is: ([full code source](https://github.com/AlienEngine/AlienEngine/blob/features/rendering/AlienEngine/Shaders/ASL/ASLShaderCompiler.cs))\r\n```csharp\r\ninternal static KeyValuePair<MethodDefinition, KeyValuePair<string, string>> CreateMethodString(TypeDefinition s, MethodDefinition m)\r\n{\r\n    if (s == null)\r\n        throw new ArgumentNullException(\"s\");\r\n\r\n    if (m == null)\r\n        throw new ArgumentNullException(\"m\");\r\n\r\n    var ctx = new DecompilerContext(s.Module)\r\n    {\r\n        CurrentType = s,\r\n        CurrentMethod = m,\r\n        CancellationToken = CancellationToken.None\r\n    };\r\n\r\n    var d = AstMethodBodyBuilder.CreateMethodBody(m, ctx);\r\n\r\n    var glsl = new ASLShader.GLSLVisitor(d, ctx);\r\n\r\n    var sig = ASLShader.GLSLVisitor.GetSignature(m);\r\n    var code = glsl.Result;\r\n    var desc = new KeyValuePair<MethodDefinition, KeyValuePair<string, string>>(\r\n        m,\r\n        new KeyValuePair<string, string>(m.Name, sig + code)\r\n    );\r\n\r\n    return desc;\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/icsharpcode/ILSpy/issues/comments/379577170","html_url":"https://github.com/icsharpcode/ILSpy/issues/1115#issuecomment-379577170","issue_url":"https://api.github.com/repos/icsharpcode/ILSpy/issues/1115","id":379577170,"user":{"login":"siegfriedpammer","id":344204,"avatar_url":"https://avatars3.githubusercontent.com/u/344204?v=4","gravatar_id":"","url":"https://api.github.com/users/siegfriedpammer","html_url":"https://github.com/siegfriedpammer","followers_url":"https://api.github.com/users/siegfriedpammer/followers","following_url":"https://api.github.com/users/siegfriedpammer/following{/other_user}","gists_url":"https://api.github.com/users/siegfriedpammer/gists{/gist_id}","starred_url":"https://api.github.com/users/siegfriedpammer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siegfriedpammer/subscriptions","organizations_url":"https://api.github.com/users/siegfriedpammer/orgs","repos_url":"https://api.github.com/users/siegfriedpammer/repos","events_url":"https://api.github.com/users/siegfriedpammer/events{/privacy}","received_events_url":"https://api.github.com/users/siegfriedpammer/received_events","type":"User","site_admin":false},"created_at":"2018-04-08T19:48:20Z","updated_at":"2018-04-08T19:48:20Z","author_association":"MEMBER","body":"Oh I am sorry, forgot that `Detach` is an internal extension method...\r\n\r\nyou can do the same:\r\n\r\n\t\tpublic static T Detach<T>(this T node) where T : AstNode\r\n\t\t{\r\n\t\t\tnode.Remove();\r\n\t\t\treturn node;\r\n\t\t}"}}
{"actor":{"display_login":"siegfriedpammer"}}