-
-
Notifications
You must be signed in to change notification settings - Fork 32
RFC 0070: Treat dashes and underscores as the same when comparing mod ids #70
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
base: main
Are you sure you want to change the base?
Changes from all commits
4f6c61b
f1c5847
bf3ff04
059401e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,49 @@ | ||||||||||
| # Normalise Mod ID Separators | ||||||||||
|
|
||||||||||
| ## Summary | ||||||||||
|
|
||||||||||
| Treat dashes and underscores as the same for mod id comparison purposes. | ||||||||||
|
|
||||||||||
| ## Motivation | ||||||||||
|
|
||||||||||
| An occasional cause for confusion is when two different mods only differ by underscores (`_`) and dashes(`-`) in their mod-ids. Since those characters aren't usually used to discriminate between mods, I propose we consider them as the same for the purposes of mod resolution and solving. | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
| ## Explanation | ||||||||||
|
|
||||||||||
| I propose we normalise all quilt mod-ids by replacing every dash (`-`) and underscore (`_`) with an internal character (likely `#`, but any character that's not permitted by the specification, and is unlikely to be part of the specification in the future, would work. Ascii is preferable due to string optimisations though). | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Moved this discussion down to the "Unresolved questions" section. |
||||||||||
|
|
||||||||||
| This normalisation would purely happen internally to quilt-loader, and wouldn't be shown to users, or exposed in methods like `ModContainer.getId()`. Instead this would allow dependencies and breaks to accidently target the wrong ID without causing issues, and would automatically cause mods with underscores or dashes to "provide" the other representations automatically. | ||||||||||
|
|
||||||||||
| For example, a mod with an ID "potion_craft-expanded" would result in: | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| - `QuiltLoader.getModContainer("potion_craft-expanded")` would return the mod | ||||||||||
| - `QuiltLoader.getModContainer("potion-craft-expanded")` would return the same mod | ||||||||||
| - The same mod is also returned for strings `potion_craft_expanded` and `potion-craft_expanded` | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| - The returned `ModContainer` will return `potion_craft-expanded` from `ModContainer.metadata().id()`. | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| - `QuiltLoader.isModLoaded` would return true for all 4 strings | ||||||||||
| - `QuiltLoader.getEntrypoints` would return the same entrypoint list for each id. | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| - `QuiltLoader.getAllMods()` will only contain a single entry | ||||||||||
| - `ModMetadata.provides()` would NOT contain provided entries for every possible combination, instead it would be empty (if no provided entries exist in the quilt.mod.json) | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
|
|
||||||||||
| ## Drawbacks | ||||||||||
|
|
||||||||||
| If someone intentionally uses dashes and underscores as a way to differentiate mods then their mods will be broken by this change. Personally I think this is unlikely though. | ||||||||||
|
|
||||||||||
|
|
||||||||||
| ## Rationale and Alternatives | ||||||||||
|
|
||||||||||
| We could instead normalise all dashes to underscores (or vice versa) but that has a few issues: | ||||||||||
| * During debugging, it won't be easy to tell if a string contains a normalised modid or a non-normalised id, leading to more bugs. | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| * We'd have to choose a favourite character, which could result in a fairly lengthy debate. Sidestepping that seems useful. | ||||||||||
|
|
||||||||||
| We could even remove both characters entirely during normalisation, so `quilt_loader` would get normalised to `quiltloader`. However this has another problem, in addition to those listed above: | ||||||||||
| * It disallows the use of separator characters in mod-ids, which are genuinly quite useful. | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
| ## Prior Art | ||||||||||
|
|
||||||||||
| I'm not aware of forge, fabric, or quilt related projects doing this before. | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
| ## Unresolved questions | ||||||||||
|
|
||||||||||
| I'm not certain what character should be used, but '#' seems like a good candidate. | ||||||||||
| I'm not sure if calls to `QuiltLoader.getModContainer` or `QuiltLoader.isModLoaded` using the normalised ID should return the mod, null, or if that should be left unspecified. | ||||||||||
|
Comment on lines
+48
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested 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.