{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/116","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/116/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/116/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/116/events","html_url":"https://github.com/dotnet/roslyn/issues/116","id":55791981,"number":116,"title":"Extend using directives to support unbound generics","user":{"login":"sharwell","id":1408396,"avatar_url":"https://avatars.githubusercontent.com/u/1408396?v=3","gravatar_id":"","url":"https://api.github.com/users/sharwell","html_url":"https://github.com/sharwell","followers_url":"https://api.github.com/users/sharwell/followers","following_url":"https://api.github.com/users/sharwell/following{/other_user}","gists_url":"https://api.github.com/users/sharwell/gists{/gist_id}","starred_url":"https://api.github.com/users/sharwell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharwell/subscriptions","organizations_url":"https://api.github.com/users/sharwell/orgs","repos_url":"https://api.github.com/users/sharwell/repos","events_url":"https://api.github.com/users/sharwell/events{/privacy}","received_events_url":"https://api.github.com/users/sharwell/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/Feature%20Request","name":"Feature Request","color":"fc2929"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Language-C%23","name":"Language-C#","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-01-28T18:01:58Z","updated_at":"2015-07-17T12:26:19Z","closed_at":null,"body":"I propose extending the **Using alias directives** feature of C# as follows.\r\n\r\n> *using-alias-directive*:\r\n> &nbsp;&nbsp;&nbsp;&nbsp;`using` *identifier* `=` *namespace-or-type-name* `;`\r\n> &nbsp;&nbsp;&nbsp;&nbsp;`using` *identifier* *generic-dimension-specifier* `=` *unbound-type-name* `;`\r\n\r\nThe *generic-dimension-specifier* and *unbound-type-name* productions are defined in the C# Language Specification description of the `typeof` operator.\r\n\r\nThe semantics of an unbound using alias directive are almost identical to the semantics of using alias directives as we know them; they merely provide the ability to associate a generic arity to the alias. The following additional requirements would be in effect:\r\n\r\n* It is a compile-time error if the *generic-dimension-specifier* and *unbound-type-name* do not have the same generic arity.\r\n\r\nSince this proposal is intended to solve a specific limitation in the support for `using` directives (for which there is no real workaround), it is written in the simplest form possible. It neither provides nor prevents a future expansion of the language from supporting partially-bound type parameters in a using alias directive; I believe this is a problem for another time.\r\n\r\n### Example\r\n\r\nC# currently allows the following using statements:\r\n\r\n```csharp\r\nusing System.Collections.Generic;\r\nusing MyList = System.Collections.Generic.List<string>;\r\n```\r\n\r\nThis expansion would additionally allow the following:\r\n\r\n```csharp\r\nusing List<> = System.Collections.Generic.List<>;\r\n```\r\n\r\nOne might argue that the duplication of `<>` on the left and right sides would be unnecessary. I believe the syntax should appear this way for the following reasons:\r\n\r\n1. With the exception of `var`, C# consistently requires types to specify generic type arguments or generic arity when referencing types. Using inference in this specific case would be misleading, especially for the following:\r\n\r\n    ```csharp\r\n    using List = System.Collections.ArrayList;\r\n    using List = System.Collections.Generic.List<>; // arity inference here is confusing\r\n    ```\r\n\r\n2. Arity inference could cause future challenges to a language extension designed to support partially-bound type parameters in a using alias directive."},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/122260314","html_url":"https://github.com/dotnet/roslyn/issues/116#issuecomment-122260314","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/116","id":122260314,"user":{"login":"leppie","id":127666,"avatar_url":"https://avatars.githubusercontent.com/u/127666?v=3","gravatar_id":"","url":"https://api.github.com/users/leppie","html_url":"https://github.com/leppie","followers_url":"https://api.github.com/users/leppie/followers","following_url":"https://api.github.com/users/leppie/following{/other_user}","gists_url":"https://api.github.com/users/leppie/gists{/gist_id}","starred_url":"https://api.github.com/users/leppie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leppie/subscriptions","organizations_url":"https://api.github.com/users/leppie/orgs","repos_url":"https://api.github.com/users/leppie/repos","events_url":"https://api.github.com/users/leppie/events{/privacy}","received_events_url":"https://api.github.com/users/leppie/received_events","type":"User","site_admin":false},"created_at":"2015-07-17T12:26:19Z","updated_at":"2015-07-17T12:26:19Z","body":"I realised I made a mistake, on that could not be aliased at all:\r\n```\r\nclass Cons<C, D> { }\r\nclass List<T> : Cons<T, List<T>> { }\r\n```\r\nTrying to alias `List<T>` would lead to an infinite expansion:\r\n```\r\nusing List<T> = Cons<T, List<T>>;\r\n```\r\nIt would be nice though to define equivalent types like that without using inheritance. I have no idea how though ;p"}}