Skip to content

Commit

Permalink
Add a mechanism to separate internal and external default experiments
Browse files Browse the repository at this point in the history
Summary:
This diff provides a temporary mechanism to allow different experiments to be enabled by default between internal and external builds of IGListKit. It works similarly to `IGListAssert` where a different copy of `IGListDefaultExperiments.h` is provided by BUCK when performing internal builds.

For the open source copies of IGListKit, the standard system behaviour of triggering an `NSInconsistencyException` when an invalid batch transaction occurs is set. For internal builds, the `IGListExperimentThrowOnInconsistencyException` experiment is disabled, where invalid transactions are forwarded to `IGListAssert` instead.

Differential Revision: D54571550

fbshipit-source-id: c6c339de20c24eb487846b6567d6c8bc08bc20f2
  • Loading branch information
TimOliver authored and facebook-github-bot committed Mar 12, 2024
1 parent eeb5208 commit 7f20f5c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
6 changes: 6 additions & 0 deletions IGListKit.xcodeproj/project.pbxproj
Expand Up @@ -420,6 +420,8 @@
E8D312E01FC472A60009FA2F /* IGListContentInsetTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E8D312DF1FC472A60009FA2F /* IGListContentInsetTests.m */; };
F102DBBB2ACE4CD500394DB7 /* IGListArrayUtilsInternal.m in Sources */ = {isa = PBXBuildFile; fileRef = F102DBBA2ACE4CD500394DB7 /* IGListArrayUtilsInternal.m */; };
F102DBBC2ACE4CD500394DB7 /* IGListArrayUtilsInternal.m in Sources */ = {isa = PBXBuildFile; fileRef = F102DBBA2ACE4CD500394DB7 /* IGListArrayUtilsInternal.m */; };
F10C8F572B982EE6009F4690 /* IGListDefaultExperiments.h in Headers */ = {isa = PBXBuildFile; fileRef = F10C8F562B982DFD009F4690 /* IGListDefaultExperiments.h */; };
F10C8F582B982EE7009F4690 /* IGListDefaultExperiments.h in Headers */ = {isa = PBXBuildFile; fileRef = F10C8F562B982DFD009F4690 /* IGListDefaultExperiments.h */; };
F10C8F5B2B9830F0009F4690 /* IGListTestCollectionViewLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = F10C8F592B9830E6009F4690 /* IGListTestCollectionViewLayout.m */; };
F10C8F5C2B9830F1009F4690 /* IGListTestCollectionViewLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = F10C8F592B9830E6009F4690 /* IGListTestCollectionViewLayout.m */; };
F1855A4C29BC565600558D18 /* IGListDiffDescriptionStringTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F1855A4B29BC565600558D18 /* IGListDiffDescriptionStringTests.m */; };
Expand Down Expand Up @@ -753,6 +755,7 @@
E56B7B3320A9D7100071010C /* IGListCollectionScrollingTraitsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGListCollectionScrollingTraitsTests.m; sourceTree = "<group>"; };
E8D312DF1FC472A60009FA2F /* IGListContentInsetTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IGListContentInsetTests.m; sourceTree = "<group>"; };
F102DBBA2ACE4CD500394DB7 /* IGListArrayUtilsInternal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGListArrayUtilsInternal.m; sourceTree = "<group>"; };
F10C8F562B982DFD009F4690 /* IGListDefaultExperiments.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IGListDefaultExperiments.h; sourceTree = "<group>"; };
F10C8F592B9830E6009F4690 /* IGListTestCollectionViewLayout.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IGListTestCollectionViewLayout.m; sourceTree = "<group>"; };
F10C8F5A2B9830E6009F4690 /* IGListTestCollectionViewLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IGListTestCollectionViewLayout.h; sourceTree = "<group>"; };
F1855A4B29BC565600558D18 /* IGListDiffDescriptionStringTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGListDiffDescriptionStringTests.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -967,6 +970,7 @@
7A02CF892361513500B49FAE /* IGListDebugger.m */,
7A02CF832361513500B49FAE /* IGListDebuggingUtilities.h */,
7A02CF8B2361513500B49FAE /* IGListDebuggingUtilities.m */,
F10C8F562B982DFD009F4690 /* IGListDefaultExperiments.h */,
7A02CF642361513300B49FAE /* IGListDisplayHandler.h */,
7A02CF802361513500B49FAE /* IGListDisplayHandler.m */,
57B22E7C2502AAC40055DC2F /* IGListItemUpdatesCollector.h */,
Expand Down Expand Up @@ -1339,6 +1343,7 @@
7A02CFA92361513600B49FAE /* UICollectionViewLayout+InteractiveReordering.h in Headers */,
E03DEA83255C9AAC00ACCAFC /* IGListTransitionData.h in Headers */,
0A89290026CDA632003FABD8 /* IGListBatchUpdateTransaction.h in Headers */,
F10C8F582B982EE7009F4690 /* IGListDefaultExperiments.h in Headers */,
0A8928FB26CDA591003FABD8 /* IGListReloadTransaction.h in Headers */,
0A8928FA26CDA53B003FABD8 /* IGListUpdateTransactionBuilder.h in Headers */,
0A8928FE26CDA5EA003FABD8 /* IGListDataSourceChangeTransaction.h in Headers */,
Expand Down Expand Up @@ -1410,6 +1415,7 @@
7A02CF452361511100B49FAE /* IGListAdapterPerformanceDelegate.h in Headers */,
7A02D0022361513600B49FAE /* IGListSectionControllerInternal.h in Headers */,
7A02CFC92361513600B49FAE /* UICollectionView+IGListBatchUpdateData.h in Headers */,
F10C8F572B982EE6009F4690 /* IGListDefaultExperiments.h in Headers */,
7A02CEF12361511100B49FAE /* IGListScrollDelegate.h in Headers */,
7A02CFF62361513600B49FAE /* IGListSectionMap+DebugDescription.h in Headers */,
F18CC76A29EFBD0300DC3B9A /* IGListBindingSingleSectionController.h in Headers */,
Expand Down
5 changes: 4 additions & 1 deletion Source/IGListKit/IGListAdapter.m
Expand Up @@ -13,11 +13,12 @@
#import <IGListDiffKit/IGListAssert.h>
#endif
#import "IGListAdapterUpdater.h"
#import "IGListSupplementaryViewSource.h"

#import "IGListArrayUtilsInternal.h"
#import "IGListDebugger.h"
#import "IGListDefaultExperiments.h"
#import "IGListSectionControllerInternal.h"
#import "IGListSupplementaryViewSource.h"
#import "IGListTransitionData.h"
#import "IGListUpdatingDelegate.h"
#import "UICollectionViewLayout+InteractiveReordering.h"
Expand Down Expand Up @@ -64,6 +65,8 @@ - (instancetype)initWithUpdater:(id <IGListUpdatingDelegate>)updater
_updater = updater;
_viewController = viewController;

_experiments = IGListDefaultExperiments();

[IGListDebugger trackAdapter:self];
}
return self;
Expand Down
2 changes: 2 additions & 0 deletions Source/IGListKit/IGListAdapterUpdater.m
Expand Up @@ -14,6 +14,7 @@
#endif

#import "IGListAdapterUpdaterHelpers.h"
#import "IGListDefaultExperiments.h"
#import "IGListIndexSetResultInternal.h"
#import "IGListMoveIndexPathInternal.h"
#import "IGListReloadIndexPath.h"
Expand All @@ -37,6 +38,7 @@ - (instancetype)init {
if (self = [super init]) {
_transactionBuilder = [IGListUpdateTransactionBuilder new];
_allowsReloadingOnTooManyUpdates = YES;
_experiments = IGListDefaultExperiments();
}
return self;
}
Expand Down
19 changes: 19 additions & 0 deletions Source/IGListKit/Internal/IGListDefaultExperiments.h
@@ -0,0 +1,19 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#import <Foundation/Foundation.h>

#if __has_include(<IGListDiffKit/IGListDiffKit.h>)
#import <IGListDiffKit/IGListExperiments.h>
#else
#import "IGListExperiments.h"
#endif

/// Provides a list of experiments that are enabled by default in IGListKit.
static inline IGListExperiment IGListDefaultExperiments(void) {
return IGListExperimentThrowOnInconsistencyException;
}

0 comments on commit 7f20f5c

Please sign in to comment.