{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/corefx/issues/4608","labels_url":"https://api.github.com/repos/dotnet/corefx/issues/4608/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/4608/comments","events_url":"https://api.github.com/repos/dotnet/corefx/issues/4608/events","html_url":"https://github.com/dotnet/corefx/issues/4608","id":118023185,"number":4608,"title":"Consistent ToString() implementations","user":{"login":"mattwarren","id":157298,"avatar_url":"https://avatars.githubusercontent.com/u/157298?v=3","gravatar_id":"","url":"https://api.github.com/users/mattwarren","html_url":"https://github.com/mattwarren","followers_url":"https://api.github.com/users/mattwarren/followers","following_url":"https://api.github.com/users/mattwarren/following{/other_user}","gists_url":"https://api.github.com/users/mattwarren/gists{/gist_id}","starred_url":"https://api.github.com/users/mattwarren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattwarren/subscriptions","organizations_url":"https://api.github.com/users/mattwarren/orgs","repos_url":"https://api.github.com/users/mattwarren/repos","events_url":"https://api.github.com/users/mattwarren/events{/privacy}","received_events_url":"https://api.github.com/users/mattwarren/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/corefx/labels/Design%20Discussion","name":"Design Discussion","color":"5319e7"},{"url":"https://api.github.com/repos/dotnet/corefx/labels/suggestion","name":"suggestion","color":"207de5"}],"state":"open","locked":false,"assignee":{"login":"KrzysztofCwalina","id":9724236,"avatar_url":"https://avatars.githubusercontent.com/u/9724236?v=3","gravatar_id":"","url":"https://api.github.com/users/KrzysztofCwalina","html_url":"https://github.com/KrzysztofCwalina","followers_url":"https://api.github.com/users/KrzysztofCwalina/followers","following_url":"https://api.github.com/users/KrzysztofCwalina/following{/other_user}","gists_url":"https://api.github.com/users/KrzysztofCwalina/gists{/gist_id}","starred_url":"https://api.github.com/users/KrzysztofCwalina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KrzysztofCwalina/subscriptions","organizations_url":"https://api.github.com/users/KrzysztofCwalina/orgs","repos_url":"https://api.github.com/users/KrzysztofCwalina/repos","events_url":"https://api.github.com/users/KrzysztofCwalina/events{/privacy}","received_events_url":"https://api.github.com/users/KrzysztofCwalina/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/dotnet/corefx/milestones/6","html_url":"https://github.com/dotnet/corefx/milestones/1.0.0-rc2","labels_url":"https://api.github.com/repos/dotnet/corefx/milestones/6/labels","id":1365455,"number":6,"title":"1.0.0-rc2","description":"","creator":{"login":"joshfree","id":1302850,"avatar_url":"https://avatars.githubusercontent.com/u/1302850?v=3","gravatar_id":"","url":"https://api.github.com/users/joshfree","html_url":"https://github.com/joshfree","followers_url":"https://api.github.com/users/joshfree/followers","following_url":"https://api.github.com/users/joshfree/following{/other_user}","gists_url":"https://api.github.com/users/joshfree/gists{/gist_id}","starred_url":"https://api.github.com/users/joshfree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshfree/subscriptions","organizations_url":"https://api.github.com/users/joshfree/orgs","repos_url":"https://api.github.com/users/joshfree/repos","events_url":"https://api.github.com/users/joshfree/events{/privacy}","received_events_url":"https://api.github.com/users/joshfree/received_events","type":"User","site_admin":false},"open_issues":167,"closed_issues":117,"state":"open","created_at":"2015-10-20T04:29:15Z","updated_at":"2015-11-24T02:18:49Z","due_on":"2016-02-02T08:00:00Z","closed_at":null},"comments":5,"created_at":"2015-11-20T11:40:47Z","updated_at":"2015-11-24T09:52:03Z","closed_at":null,"body":"At the moment some classes override `ToString()` and some don't. So it means that if you call `ToString()` on an object for debugging/logging purposes you may get something useful or you may just get the default which is the fully qualified `Type` name.\r\n\r\nTo see how widespread this is, I wrote a [simple app using Cecil](https://gist.github.com/mattwarren/33edc6d07ea087542ccb) (please let me know if my logic is wrong).\r\n\r\nHere's the lists of types that don't override ToString():\r\n- [Value types](https://gist.github.com/mattwarren/1dc37901be49a18a7204) and a [shorter summary](https://gist.github.com/mattwarren/afba4b325f02e66db419)\r\n- [Reference types](https://gist.github.com/mattwarren/3bcecf5d2b9810c48b41) and a [shorter summary](https://gist.github.com/mattwarren/79cc5669e1e4ebae6a46)\r\n\r\nIs there any desire to be more consistent across types or is it not something that people worry about? Is it expected that `[DebuggerDisplayAttribute]` should be used instead?\r\n\r\nFor instance in Java you can call ToString() on an object and you always gets something meaningful back. This even extends to collections, it calls ToString() on each item in the collection and appends those into a string, which might be going a bit too far.\r\n\r\n**Useful links**:\r\n- [Object.ToString Method ()](https://msdn.microsoft.com/en-us/library/system.object.tostring.aspx)\r\n- [Framework Design Guidelines: Overriding Object.ToString()](http://blogs.msdn.com/b/brada/archive/2009/02/02/framework-design-guidelines-overriding-object-tostring.aspx)\r\n- [Why override ToString()? Use DebuggerDisplayAttribute instead](http://blogs.msdn.com/b/soultech/archive/2011/04/05/whyoverridetostring_2d00_use_2d00_debuggerdisplayattribute_2d00_instead.aspx)"},"comment":{"url":"https://api.github.com/repos/dotnet/corefx/issues/comments/159211997","html_url":"https://github.com/dotnet/corefx/issues/4608#issuecomment-159211997","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/4608","id":159211997,"user":{"login":"mattwarren","id":157298,"avatar_url":"https://avatars.githubusercontent.com/u/157298?v=3","gravatar_id":"","url":"https://api.github.com/users/mattwarren","html_url":"https://github.com/mattwarren","followers_url":"https://api.github.com/users/mattwarren/followers","following_url":"https://api.github.com/users/mattwarren/following{/other_user}","gists_url":"https://api.github.com/users/mattwarren/gists{/gist_id}","starred_url":"https://api.github.com/users/mattwarren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattwarren/subscriptions","organizations_url":"https://api.github.com/users/mattwarren/orgs","repos_url":"https://api.github.com/users/mattwarren/repos","events_url":"https://api.github.com/users/mattwarren/events{/privacy}","received_events_url":"https://api.github.com/users/mattwarren/received_events","type":"User","site_admin":false},"created_at":"2015-11-24T09:52:03Z","updated_at":"2015-11-24T09:52:03Z","body":"@weshaggard, @KrzysztofCwalina \r\n\r\n> What information would you try to put into all these ToString's? I agree that if an class has something useful then it might be worth overriding it's ToString but there really isn't any consistent way to provide a meaningful value in a programmatic way. For that reason I wouldn't try and do this holistically across all the types in the framework.\r\n\r\nYeah I agree, my original intent for this issue was to see if there was any desire to change (one-by-one) all the classes that don't override `ToString()`. So that they individually return something meaningful for that class, not do it in one place for all classes/types.\r\n\r\n> As for the compat bar anything we changed here that also exists on the .NET Framework we should expect that change to go to the .NET Framework and as such the bar would be pretty high. I wouldn't change them unless there is actually some value to changing them.\r\n\r\nI didn't think about that, I (naively) thought that these changes could just be made in DNX/CoreCLR and not have to be ported back for the .NET Framework, so that changes things.\r\n\r\nBased on the lack of response from (almost) anyone else, I guess that not many people are bothered about whether `ToString()` consistently returns something meaningful or not. I admit it's a bit of a niche concern ;-)\r\n\r\nSo I'm thinking that if I or someone else wants `ToString()` overridden in a specific class, then an issue can be raised for that class and dealt with on a case-by-case basis, rather than in a holistic way, do you agree?"}}