Skip to content
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

Draft
wants to merge 21 commits into
base: dev
Choose a base branch
from

Conversation

NebelNidas
Copy link
Member

@NebelNidas NebelNidas commented May 9, 2023

Reduces redundancy and allows API consumers to have direct access to all standard properties.

@NebelNidas NebelNidas force-pushed the tiny-properties-class branch from be4f9d5 to 48798f9 Compare May 13, 2023 22:44
@NebelNidas NebelNidas force-pushed the tiny-properties-class branch from 48798f9 to 33ccdd5 Compare June 16, 2023 08:33
@NebelNidas NebelNidas marked this pull request as ready for review June 16, 2023 08:34
@NebelNidas
Copy link
Member Author

NebelNidas commented Jun 30, 2023

Hmm, should I rename to class to TinyFormatStandardProperties?

@NebelNidas NebelNidas changed the title Move Tiny format properties into separate class Create cross-format Standard Properties class Sep 15, 2023
- Now supports `component` intermediary counter
- Removes some hardcoded values
- Tiny v1 now supports reading arbitrary metadata (prefixed with `#`)
}

@ApiStatus.Internal
public static StandardProperty getById(String id) {
Copy link

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.

Copy link
Member Author

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

Copy link

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.

Copy link
Member Author

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

Copy link
Member Author

@NebelNidas NebelNidas Sep 25, 2023

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?

Copy link

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.

Copy link
Member Author

@NebelNidas NebelNidas Oct 10, 2023

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.

@modmuss50 modmuss50 self-requested a review September 28, 2023 18:40
@NebelNidas NebelNidas changed the title Create cross-format Standard Properties class Create cross-format StandardProperties class Oct 10, 2023
@modmuss50 modmuss50 added this to the 0.6.0 milestone Nov 21, 2023
@NebelNidas NebelNidas requested a review from liach March 7, 2024 17:55
@NebelNidas
Copy link
Member Author

Oops, I wanted to request the review from Modmuss, sorry 😅

Comment on lines +47 to +50
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;
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member Author

@NebelNidas NebelNidas Mar 8, 2024

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

Copy link
Member Author

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

Copy link

@liach liach left a 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.

@NebelNidas
Copy link
Member Author

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.

That's the nice thing, MIO already used the same standardized values internally before, so this whole PR is 100% backward compatible :)

@NebelNidas
Copy link
Member Author

Postponing to a later release, since I need to rewrite this to be more extensible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants