-
Notifications
You must be signed in to change notification settings - Fork 806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement NSArray descriptionWithLocale* methods #2256
Conversation
Frameworks/Foundation/NSArray.mm
Outdated
return StubReturn(); | ||
thread_local unsigned int indent = 0; | ||
NSMutableString* s = [NSMutableString string]; | ||
NSString* indentStr = (level == 0) ? @" " : @"\t"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm torn on how this is supposed to work. Shouldn't it call the next one with the next level
, and always make sure to indent itself to this level
? The thread local becomes superfluous, and it's initialized with the wrong value anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://developer.apple.com/reference/foundation/nsarray/1416257-descriptionwithlocale
UPDATE: this is possibly the most misleading documentation I have read 👎
…ntation was still rather confusing but despite the previous failure this changes the [NSArray descriptionWithLocale:indent:] to propertly use indent to propogate the indentation level which will be useable (once implemented) in NSDictionary, NSSet, etc.
++level; | ||
auto deferPop = wil::ScopeExit([&level]() { --level; }); | ||
for (id val in self) { | ||
for (unsigned int i = 0; i < level; ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not sure this is totally correct; if you nest arrays, you'll double-indent them because you're appending level*"spaces"
, and then passing level to the nested value which will prepend level*"spaces"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be expected behavior, our test for NSArray description depth still passes w/ this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:(
i guess we should file a task to do this for dictionary too.
Fixes #2073