-
Notifications
You must be signed in to change notification settings - Fork 19
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
Create cross-format StandardProperties
class
#29
base: dev
Are you sure you want to change the base?
Conversation
be4f9d5
to
48798f9
Compare
48798f9
to
33ccdd5
Compare
src/main/java/net/fabricmc/mappingio/format/tiny/TinyProperties.java
Outdated
Show resolved
Hide resolved
|
- Now supports `component` intermediary counter - Removes some hardcoded values - Tiny v1 now supports reading arbitrary metadata (prefixed with `#`)
7f6258f
to
0910fa9
Compare
src/main/java/net/fabricmc/mappingio/format/StandardProperties.java
Outdated
Show resolved
Hide resolved
src/main/java/net/fabricmc/mappingio/format/StandardProperties.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@ApiStatus.Internal | ||
public static StandardProperty getById(String id) { |
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 design is bad: malicious actors can fake an id and pollute the metadata detection. You should just keep a Map<MappingFormat, Map<String, StandardProperty>>
instead.
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.
Not sure what you mean, the internal maps are all private 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.
Say if you have a next-intermediary-method
read from tiny v1, you would incorrectly interpret it as an intermediary counter while it isn'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've already added a sanity check preventing this: 5341ecf
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.
The issue why I need a simple String ID instead of a Map<MappingFormat, Map<String, StandardProperty>>
is intermediate operations, say MemoryMappingTree.accept(MemoryMappingTree)
, where none of the participants know which mapping format the former tree was originally constructed from. I could generate a random ID per session, but IMO that's overcomplicating things without much reason. Maybe prepending the existing ID with mio:
would do?
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.
Can we just add a new default void visitStandardProperty(StandardProperty prop, String value)
in MappingVisitor
and FlatMappingVisitor
, which fabric's builtin visitors will override? And we can choose to feed these standard properties back as String key-values in visit options.
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.
Hmm, not a huge fan of this, since up until this point the visitor- and tree-based APIs have always been cleanly separated.
Edit: On the other hand, StandardProperty
isn't really part of the tree-api, so maybe it'd work? But it still duplicates the metadata visit methods, which pollute the FlatMappingVisitor
interface, especially considering #41 will add even more.
Don't expose more functionality than currently required, to reduce the API surface we need to maintain.
StandardProperties
class
Oops, I wanted to request the review from Modmuss, sorry 😅 |
public static final StandardProperty NEXT_INTERMEDIARY_CLASS; | ||
public static final StandardProperty NEXT_INTERMEDIARY_FIELD; | ||
public static final StandardProperty NEXT_INTERMEDIARY_METHOD; | ||
public static final StandardProperty NEXT_INTERMEDIARY_COMPONENT; |
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.
Im not sure these should exist in mio, they are specific to intermediary and are generated by matcher. They arent part of the tiny format, and I dont think we actually read them anymore?
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.
happy to discuss this if you think otherwise.
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'd say this is a bit of an edge-case, since the counters have been special-cased until now and consequently behaved as de-facto standard properties. I could remove it, so we end up using the INTERMEDIARY_COUNTER
notation in Tiny v2, too, though this would conflict with existing naming conventions and we would be stuck with a misleading name. We could of course also delegate this responsibility to Matcher, which would have to do the conversion via a custom forwarding visitor pass
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.
In the long run we might need an API letting consumers register their own standard properties
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.
Also for preventing clash of property id with mapping's native properties, should we declare a new MappingFlag to alert mapping visitors? Also to preserve backward compatibility if say, an old tinyv1 visitor still anticipates old property keys instead of the standardized ones. If a visitor anticipates standardized keys, they should declare the new flag in their mapping flags.
Otherwise this whole thing looks pretty good, a huge improvement from the initial revision.
src/main/java/net/fabricmc/mappingio/format/StandardProperties.java
Outdated
Show resolved
Hide resolved
src/main/java/net/fabricmc/mappingio/format/StandardProperties.java
Outdated
Show resolved
Hide resolved
That's the nice thing, MIO already used the same standardized values internally before, so this whole PR is 100% backward compatible :) |
Postponing to a later release, since I need to rewrite this to be more extensible |
Reduces redundancy and allows API consumers to have direct access to all standard properties.