REFACTOR: Mitigate cyclic dependency between Jsonable classes #1792
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
All Jsonable classes depend on
constructorsForReviver
insrc\utils\JSONReviver.ts
, andJSONReviver
has a complicated dependency tree due toloadActionIdentifier
insrc\Bladeburner\utils\loadActionIdentifier.ts
. This tree can create a cyclic dependency between Jsonable classes.Jest test:
MRE:
src\Settings\Settings.ts
, importStock
fromsrc\StockMarket\Stock.ts
and use it.Log:
Problem:
Player
depends onReviver
insrc\utils\JSONReviver.ts
.JSONReviver.ts
depends onloadActionIdentifier
insrc\Bladeburner\utils\loadActionIdentifier.ts
.loadActionIdentifier.ts
has a complicated dependency tree. In this case, the tree containsStock
insrc\StockMarket\Stock.ts
.Stock.ts
needs to accessconstructorsForReviver
insrc\utils\JSONReviver.ts
, butconstructorsForReviver
is undefined at this point.This PR mitigates this problem:
cyrb53
out ofsrc\utils\StringHelperFunctions.ts
: CutAlertManager
->StringHelperFunctions
.handleUnknownError
andhandleGetSaveDataInfoError
out ofsrc\Netscript\ErrorMessages.ts
: CutErrorMessages
->DialogBox
.Reviver
out ofsrc\utils\JSONReviver.ts
: CutJSONReviver
->loadActionIdentifier
.Another mitigation is to move
constructorsForReviver
out ofsrc\utils\JSONReviver.ts
to cut "all Jsonable classes" ->JSONReviver
. This mitigation will change all Jsonable classes, so I have not implemented it.