{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/corefx/issues/1501","labels_url":"https://api.github.com/repos/dotnet/corefx/issues/1501/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/1501/comments","events_url":"https://api.github.com/repos/dotnet/corefx/issues/1501/events","html_url":"https://github.com/dotnet/corefx/issues/1501","id":70591326,"number":1501,"title":"Proposal: Runtime Feature Testing","user":{"login":"prasannavl","id":559409,"avatar_url":"https://avatars.githubusercontent.com/u/559409?v=3","gravatar_id":"","url":"https://api.github.com/users/prasannavl","html_url":"https://github.com/prasannavl","followers_url":"https://api.github.com/users/prasannavl/followers","following_url":"https://api.github.com/users/prasannavl/following{/other_user}","gists_url":"https://api.github.com/users/prasannavl/gists{/gist_id}","starred_url":"https://api.github.com/users/prasannavl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prasannavl/subscriptions","organizations_url":"https://api.github.com/users/prasannavl/orgs","repos_url":"https://api.github.com/users/prasannavl/repos","events_url":"https://api.github.com/users/prasannavl/events{/privacy}","received_events_url":"https://api.github.com/users/prasannavl/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-04-24T05:27:47Z","updated_at":"2015-04-28T10:54:10Z","closed_at":"2015-04-28T10:54:10Z","body":"### The Problem: \r\n\r\nDetection of .NET Runtime has never been reliable. One could either using Reflection to drill into the version info, look at the Environment and so on. This SO question http://stackoverflow.com/questions/8517159/how-to-detect-at-runtime-that-net-version-4-5-currently-running-your-code/8543850#8543850, and its answer gives an idea of the better approaches to do. But there is no one constant way to do it.\r\n\r\n### The Solution:\r\n\r\nIntroduce a runtime feature class, which does feature testing. And this is also a place where external libraries loaded can add their own feature-set, so version testing is essentially not required at all. You test for the feature you need, and proceed ahead based on that. \r\n\r\n```c#\r\nnamespace System.Diagnostics\r\n\r\npublic static class Features\r\n{\r\npublic static bool IsAvailable(string feature);\r\n\r\n// Checks if the executing assembly name is prefixed first, or else throws, ensuring that\r\n// only the correct assemblies add them. (There is of course reflection if tricking is\r\n// indeed the developer's intention).\r\n\r\npublic static void AddFeature(string feature); \r\n\r\npublic static void RemoveFeature(string feature);\r\npublic static IEnumerable<string> GetAllFeatures();\r\n\r\npublic event Action<string, FeatureChangeAction> FeatureChanged; \r\n\r\npublic enum FeatureChangeAction {\r\nAdded, Removed,\r\n}\r\n\r\npublic static class InternalFeatures\r\n{\r\npublic const string ReflectionContext = \"mscorlib.net45refl\"\r\n}\r\n\r\n}\r\n\r\n```\r\n\r\nImplementation of this could just be a simple dictionary. This avoids the need to know what to look for for each feature, and provides a consistency in checking for features."},"comment":{"url":"https://api.github.com/repos/dotnet/corefx/issues/comments/97015145","html_url":"https://github.com/dotnet/corefx/issues/1501#issuecomment-97015145","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/1501","id":97015145,"user":{"login":"prasannavl","id":559409,"avatar_url":"https://avatars.githubusercontent.com/u/559409?v=3","gravatar_id":"","url":"https://api.github.com/users/prasannavl","html_url":"https://github.com/prasannavl","followers_url":"https://api.github.com/users/prasannavl/followers","following_url":"https://api.github.com/users/prasannavl/following{/other_user}","gists_url":"https://api.github.com/users/prasannavl/gists{/gist_id}","starred_url":"https://api.github.com/users/prasannavl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prasannavl/subscriptions","organizations_url":"https://api.github.com/users/prasannavl/orgs","repos_url":"https://api.github.com/users/prasannavl/repos","events_url":"https://api.github.com/users/prasannavl/events{/privacy}","received_events_url":"https://api.github.com/users/prasannavl/received_events","type":"User","site_admin":false},"created_at":"2015-04-28T10:54:10Z","updated_at":"2015-04-28T10:54:10Z","body":"Sorry for the late reply. And yes, I just glanced through the AppContext, and I believe that should take care of my all the intentions mentioned in this issue.\r\n\r\n@AlexGhiondea, thanks for the brief and clearing up on the intent of AppContext. I think this issue no longer needs to remain open. Curious to see what else is going to be a part of AppContext though, since the name is quite generic implying a composition of more. "}}