-
Notifications
You must be signed in to change notification settings - Fork 14
Optionally associate reports with usages #88
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
Open
tuxedo-aer
wants to merge
1
commit into
microsoft:main
Choose a base branch
from
tuxedo-aer:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+5
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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'm not sure this solves for the general case. If you have lots of nested collections like:
If I follow the code correctly (it's been a while since my head was in this space - so to be 100% confident I'd have to build the descriptor and test it), then the usage associated with the whole report here would be one of the inner collections wrapping the first report field, even though other fields in the same report are not associated with that collection.
I think what you want is something like "usage of the most deeply nested collection that all report fields are members of"? I think that's a bit trickier to compute; but I think something like this would work:
Also, I recommend giving a more specific name to the Report.usage field to better describe what it is capturing.
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 think that is a correct description of what I want. To give an example, this is an example LampArray report from the HID spec:
As you can see, the REPORT_ID is directly followed by a USAGE before a nested collection is opened. If I'm not mistaken, it might even be the case that multiple such usages per report are possible.
In any case, parsing the descriptor without associating reports with the following usages it not very useful because the usage indicates which report is used for what.
I will have a closer look at the code you suggested and will check with my use-case over the next couple of days.
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.
Each field within the report has the full collection chain (i.e. the
member_ofvec that this code is using should also be available on each report field to the consumer) in addition to the usage for the field itself. On the consumer side, if you are looking at a particular report field within a report, you can evaluate the entire collection chain for that field and see if it has the usage you care about. For example, when processing a report field, you can write logic like "is this report field within a Collection that has LampArray Usage" just by inspecting the data associated with the report field as it is now. But that is per-field, rather than per-report.I agree that it may be useful to have some notion of what an entire report's "usage" is, but the definition of what a report's "usage" remains a bit unclear (to me, anyway) because of the complicated way that collections can nest and span within and across reports.
The above "usage of the most deeply nested collection that all report fields [of a given report id] are a member of" is my attempt to reduce that to a concrete definition, but I'm open to other well-defined alternatives, if they are more useful.
For example, you could alternatively define a report's "usage" as the set of all usages associated with the report (either as field usages or on collections including or nested within the report), which would allow for membership tests (i.e. "is this Report associated with a "LampArray" usage?" becomes a test on of whether that usage is in the Report usages set).
In any case, I am open to adding usage info at the Report level, if we can settle on a good definition of what that is that works in the general case.