{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/262","repository_url":"https://api.github.com/repos/dotnet/roslyn","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/262/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/262/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/262/events","html_url":"https://github.com/dotnet/roslyn/issues/262","id":56614758,"number":262,"title":"Proposal: support an enum constraint on generic type parameters","user":{"login":"gafter","id":3804346,"avatar_url":"https://avatars.githubusercontent.com/u/3804346?v=3","gravatar_id":"","url":"https://api.github.com/users/gafter","html_url":"https://github.com/gafter","followers_url":"https://api.github.com/users/gafter/followers","following_url":"https://api.github.com/users/gafter/following{/other_user}","gists_url":"https://api.github.com/users/gafter/gists{/gist_id}","starred_url":"https://api.github.com/users/gafter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gafter/subscriptions","organizations_url":"https://api.github.com/users/gafter/orgs","repos_url":"https://api.github.com/users/gafter/repos","events_url":"https://api.github.com/users/gafter/events{/privacy}","received_events_url":"https://api.github.com/users/gafter/received_events","type":"User","site_admin":false},"labels":[{"id":167974278,"url":"https://api.github.com/repos/dotnet/roslyn/labels/2%20-%20Ready","name":"2 - Ready","color":"CCCCCC","default":false},{"id":169838071,"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-Language%20Design","name":"Area-Language Design","color":"5319e7","default":false},{"id":166677091,"url":"https://api.github.com/repos/dotnet/roslyn/labels/Feature%20Request","name":"Feature Request","color":"fc2929","default":false},{"id":166377946,"url":"https://api.github.com/repos/dotnet/roslyn/labels/Language-C%23","name":"Language-C#","color":"207de5","default":false},{"id":166377961,"url":"https://api.github.com/repos/dotnet/roslyn/labels/Language-VB","name":"Language-VB","color":"207de5","default":false}],"state":"open","locked":false,"assignee":{"login":"AnthonyDGreen","id":10539978,"avatar_url":"https://avatars.githubusercontent.com/u/10539978?v=3","gravatar_id":"","url":"https://api.github.com/users/AnthonyDGreen","html_url":"https://github.com/AnthonyDGreen","followers_url":"https://api.github.com/users/AnthonyDGreen/followers","following_url":"https://api.github.com/users/AnthonyDGreen/following{/other_user}","gists_url":"https://api.github.com/users/AnthonyDGreen/gists{/gist_id}","starred_url":"https://api.github.com/users/AnthonyDGreen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnthonyDGreen/subscriptions","organizations_url":"https://api.github.com/users/AnthonyDGreen/orgs","repos_url":"https://api.github.com/users/AnthonyDGreen/repos","events_url":"https://api.github.com/users/AnthonyDGreen/events{/privacy}","received_events_url":"https://api.github.com/users/AnthonyDGreen/received_events","type":"User","site_admin":false},"assignees":[{"login":"AnthonyDGreen","id":10539978,"avatar_url":"https://avatars.githubusercontent.com/u/10539978?v=3","gravatar_id":"","url":"https://api.github.com/users/AnthonyDGreen","html_url":"https://github.com/AnthonyDGreen","followers_url":"https://api.github.com/users/AnthonyDGreen/followers","following_url":"https://api.github.com/users/AnthonyDGreen/following{/other_user}","gists_url":"https://api.github.com/users/AnthonyDGreen/gists{/gist_id}","starred_url":"https://api.github.com/users/AnthonyDGreen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnthonyDGreen/subscriptions","organizations_url":"https://api.github.com/users/AnthonyDGreen/orgs","repos_url":"https://api.github.com/users/AnthonyDGreen/repos","events_url":"https://api.github.com/users/AnthonyDGreen/events{/privacy}","received_events_url":"https://api.github.com/users/AnthonyDGreen/received_events","type":"User","site_admin":false}],"milestone":null,"comments":21,"created_at":"2015-02-05T01:31:28Z","updated_at":"2016-11-06T13:19:09Z","closed_at":null,"body":"Allow the constraints on a type parameter to include `enum`. Such a constrained type parameter could be instantiated with an enum type or with another type parameter that is so constrained.\n\nThis probably needs more design work.\n"},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/258680395","html_url":"https://github.com/dotnet/roslyn/issues/262#issuecomment-258680395","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/262","id":258680395,"user":{"login":"OndrejPetrzilka","id":3371096,"avatar_url":"https://avatars.githubusercontent.com/u/3371096?v=3","gravatar_id":"","url":"https://api.github.com/users/OndrejPetrzilka","html_url":"https://github.com/OndrejPetrzilka","followers_url":"https://api.github.com/users/OndrejPetrzilka/followers","following_url":"https://api.github.com/users/OndrejPetrzilka/following{/other_user}","gists_url":"https://api.github.com/users/OndrejPetrzilka/gists{/gist_id}","starred_url":"https://api.github.com/users/OndrejPetrzilka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OndrejPetrzilka/subscriptions","organizations_url":"https://api.github.com/users/OndrejPetrzilka/orgs","repos_url":"https://api.github.com/users/OndrejPetrzilka/repos","events_url":"https://api.github.com/users/OndrejPetrzilka/events{/privacy}","received_events_url":"https://api.github.com/users/OndrejPetrzilka/received_events","type":"User","site_admin":false},"created_at":"2016-11-06T13:19:09Z","updated_at":"2016-11-06T13:19:09Z","body":"@mikedn \r\n\r\n> I don't think so. Try an enum having underlying type uint and value 0x80000000. You'll likely end up with 0x0000000080000000 and 0xFFFFFFFF80000000.\r\n\r\nYou're right, this test fails\r\n\r\n> Depends on what you mean by \"better\":\r\n\r\nI was concerned about second point (verifiable/correct). How's that different from making union in C# (explicit struct layout with field offsets), because I believe that it's verifiable/correct when it contains no reference types. In worst case (performance wise), I can implement similar approach in IL as well to make it verifiable. Or union wouldn't work in IL, because it does not allow generic type in it?\r\n\r\nLets say I don't care about cast to `ulong`, I want to get the bits to perform bit operation on them. So `ulong GetBits(TEnum)` and `TEnum SetBits(ulong)` would be enough (it would use `conv.u8`)\r\n\r\nIn such case I would get \"wrong\" number, but I'd be able to apply bit operations correctly and cast it back to enum (if we figure out verifiable way). Bit operations would be: And, Or, Xor, Not, Ceq. Since there's no Add/Sub, I don't have to care about overflow and conversions.\r\n\r\nOr we can skip GetBits/SetBits completely and just implement bit operations in type-independent way. Because I think this is perfectly valid IL:\r\n\r\n```\r\n.method public hidebysig static \r\n\t!!T Clear<[mscorlib]System.Enum) T> (!!T 'value', !!T 'flags') cil managed aggressiveinlining\r\n{\r\n\tIL_0000: ldarg.0\r\n\tIL_0001: ldarg.1\r\n\tIL_0002: not\r\n\tIL_0003: and\r\n\tIL_0004: ret\r\n} // end of method EnumExtensions::Clear\r\n```\r\nI just though it would be nice to have a way of getting/setting all the bits at once as `ulong` (even when it wouldn't represent correct negative number, just the bits)."}}
{"actor":{"display_login":"OndrejPetrzilka"}}