{"action":"opened","issue":{"url":"https://api.github.com/repos/SeleniumHQ/selenium/issues/6807","repository_url":"https://api.github.com/repos/SeleniumHQ/selenium","labels_url":"https://api.github.com/repos/SeleniumHQ/selenium/issues/6807/labels{/name}","comments_url":"https://api.github.com/repos/SeleniumHQ/selenium/issues/6807/comments","events_url":"https://api.github.com/repos/SeleniumHQ/selenium/issues/6807/events","html_url":"https://github.com/SeleniumHQ/selenium/issues/6807","id":395400204,"node_id":"MDU6SXNzdWUzOTU0MDAyMDQ=","number":6807,"title":"dotnet - Adding a static getter to the 'By' class for extension methods.","user":{"login":"alexHayes08","id":11264007,"node_id":"MDQ6VXNlcjExMjY0MDA3","avatar_url":"https://avatars2.githubusercontent.com/u/11264007?v=4","gravatar_id":"","url":"https://api.github.com/users/alexHayes08","html_url":"https://github.com/alexHayes08","followers_url":"https://api.github.com/users/alexHayes08/followers","following_url":"https://api.github.com/users/alexHayes08/following{/other_user}","gists_url":"https://api.github.com/users/alexHayes08/gists{/gist_id}","starred_url":"https://api.github.com/users/alexHayes08/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexHayes08/subscriptions","organizations_url":"https://api.github.com/users/alexHayes08/orgs","repos_url":"https://api.github.com/users/alexHayes08/repos","events_url":"https://api.github.com/users/alexHayes08/events{/privacy}","received_events_url":"https://api.github.com/users/alexHayes08/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-01-02T22:22:15Z","updated_at":"2019-01-02T22:22:15Z","closed_at":null,"author_association":"NONE","body":"## 🚀 Feature Proposal\r\n\r\n**Note: Applies to dotnet only**\r\n\r\nAdd a static getter property of type `By` (or an empty class) on the `OpenQA.Selenium.By` class to allow third parties to write static extension methods targeting that property.\r\n\r\n## Motivation\r\n\r\nWhen subclassing [`OpenQA.Selenium.By`](https://seleniumhq.github.io/selenium/docs/api/dotnet/html/T_OpenQA_Selenium_By.htm)(under remarks) it recommends using static methods for instantiation instead of constructors and it would be nice to have static getter property like `By.Custom` as a target for extension methods. `MyCustomByClass.MyCustomBy(...)` would become `By.Custom.MyCustomBy(...)`. This would (in my opinion) help keep things a bit more organized when subclassing By.\r\n\r\n## Example\r\n\r\nNote: In these examples the property is named Custom since I can't think of a better name (maybe `By.From` or `By.With`?).\r\n\r\n### With a custom extension property.\r\n\r\n`public class LoginComponent : ILoadableComponent`\r\n`{`\r\n`    ...`\r\n`    By remainLoggedInSelector = By.FromCssSelector(...);`\r\n`    By userNameInputSelector = By.FromCssSelector(...);`\r\n**`    By passwordInputSelector = By.Custom.MyCustomByA(...);` <--\r\n`    By submitBtnSelector = By.Custom.MyCustomByB(...);`         <--**\r\n`    ...`\r\n`}`\r\n\r\n### Without the property\r\n`public class LoginComponent : ILoadableComponent`\r\n`{`\r\n`    ...`\r\n`    By remainLoggedInSelector = By.FromCssSelector(...);`\r\n`    By userNameInputSelector = By.FromCssSelector(...);`\r\n**`    By passwordInputSelector = ACustomBy.MyCustomBy(...);`        <--\r\n`    By submitBtnSelector = BCustomBy.MyCustomBy(...);`  <--**\r\n`    ...`\r\n`}`\r\n\r\n### Implementing\r\nIt should be relatively easy to implement (hopefully I didn't jinx it) since it doesn't add/modify any significant features.\r\n\r\n_dotnet/src/webdriver/By.cs_\r\n`public class By`\r\n`{`\r\n`...`\r\n`private static By _Custom = new By();`\r\n`public static By Custom => _By;`\r\n`...`\r\n`}`\r\n\r\nHowever this would create issues if a user tried to call `By.Custom.FindElements(...)` on the static property. A solution to this would be to create an empty class with an internal constructor and use that type instead of `By` but that might be overkill.\r\n\r\n_dotnet/src/webdriver/ByExtensionPoint.cs_\r\n`public class ByExtensionPoint`\r\n`{`\r\n`internal ByExtensionPoint() {  }`\r\n`}`\r\n\r\n_dotnet/src/webdriver/By.cs_\r\n`public class By`\r\n`{`\r\n`...`\r\n`private static ByExtensionPoint _Custom = new ByExtensionPoint();`\r\n`public static ByExtensionPoint Custom => _By;`\r\n`...`\r\n`}`"}}
{"actor":{"display_login":"alexHayes08"}}