You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to standardize on our format for diff tags in React Native macOS. Diff tags are how we track the code diffs we have added on top of React Native to get React Native macOS compiling and working for our products. Overtime, we've shifted the format of these tags, which has resulted in less cleanliness and confusion around their purpose.
Current state
# Old single line comments, with an internal issue number
// TODO(OSS Candidate ISS#2710739)
# Current single line comments, with a public Github issue
// TODO(macOS GH#774)
# Blocks
...
// [TODO(macOS GH#774)
... code we added
// ]TODO(macOS GH#774)
...
Problems with current state
There's a mix of internal and public issue numbers, leading to inconsistent tags
"TODO" was because we thought one day we would upstream all of our diffs. That will probably never happen, so it gives the wrong impression.
# Single Line diff
// macOS
# Block Diff
...
// [macOS
...
// macOS]
...
Some feedback I got:
@harrieshin : "Brackets with words inside look like Objective C code and confuse me
@amgleitman : "It would be nice to have one phrase we can easily Cmd+Shift+F search the entire repo for all of our diff tags. // macOS and // [macOS don't allow me to do that."
Better format
Given the feedback, I came up with two new formats that satisfy the feedback I got.
A) Brackets before comment with a space
# Single Line diff
// [ macOS ]
# Block Diff
...
// [ macOS
...
// ] macOS
...
# Inline diff (new format)
/* this code adds an RCTUIView [ macOS ] to the view tree */
B) Brackets after the comment with a space
# Single Line diff
// macOS
# Block Diff
...
// macOS [
...
// macOS ]
...
# Inline diff (new format)
/* this code adds an RCTUIView [// macOS] to the view tree */
Bonus Section - ifdef blocks
Oftentimes we add a few types of ifdef blocks to React Native's iOS code:
ifdef macOS only code
#if TARGET_OS_OSX
...macOS only code
#endif
ifdef iOS only code
#if !TARGET_OS_OSX
...iOS only code
#endif
ifdef between an iOS and macOS block
#if TARGET_OS_OSX
...macOS only code
#else
...original iOS block
#endif
Purpose
I would like to standardize on our format for diff tags in React Native macOS. Diff tags are how we track the code diffs we have added on top of React Native to get React Native macOS compiling and working for our products. Overtime, we've shifted the format of these tags, which has resulted in less cleanliness and confusion around their purpose.
Current state
Problems with current state
TODO(macOS GH#774)means Track macOS specific changes that differ from upstream #774 .Proposal
Let's do something more similar to React Native Windows, which has tags that look like this:
The current format in my PR (#1392 ) looks like:
Some feedback I got:
// macOSand// [macOSdon't allow me to do that."Better format
Given the feedback, I came up with two new formats that satisfy the feedback I got.
A) Brackets before comment with a space
B) Brackets after the comment with a space
Bonus Section - ifdef blocks
Oftentimes we add a few types of ifdef blocks to React Native's iOS code:
Should tags be on the same line?
A) Same line
B) Different line
Should iOS ifdef blocks be single line or block tags?
A) Two single line tags
Rationale: A block makes it look like we're adding this code when we aren't. This is the current state.
B) Block tag
Rationale: The two ifdef tags do correspond to each other, even if the code inside isn't our addition
Final Poll
(In a bit of cheating, I made my preference for each question the first option, AKA (a)