-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor encoded annotation value resolution to use parsed type tags #64
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
Conversation
Co-authored-by: futpib <4330357+futpib@users.noreply.github.com>
Co-authored-by: futpib <4330357+futpib@users.noreply.github.com>
Co-authored-by: futpib <4330357+futpib@users.noreply.github.com>
Co-authored-by: futpib <4330357+futpib@users.noreply.github.com>
Co-authored-by: futpib <4330357+futpib@users.noreply.github.com>
Co-authored-by: futpib <4330357+futpib@users.noreply.github.com>
Co-authored-by: futpib <4330357+futpib@users.noreply.github.com>
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.
@copilot Address all comments
…ped indices in annotations Co-authored-by: futpib <4330357+futpib@users.noreply.github.com>
|
@copilot fix this failing test, although i'm not sure which one is correct actual or expected |
…ully Co-authored-by: futpib <4330357+futpib@users.noreply.github.com>
... Fixed the failing test. The issue was that string index 0 was incorrectly treated as "undefined" in all cases. Changed to resolve all string indices (including 0) and only return |
Pull Request Test Coverage Report for Build 19264008762Details
💛 - Coveralls |
|
@copilot why do we need different resolutions function for static/non-static? |
We need two resolution functions because they handle typed indices differently: Static values (class field initial values): Keep typed indices as raw numbers. For example, a Annotations: Resolve typed indices to actual values. For example:
This is necessary because annotations semantically represent metadata with human-readable values (like Signature annotations with string arrays), while static values represent initial field values that reference other DEX structures by index. |
Refactoring Encoded Annotation Value Resolution - COMPLETE
Summary
Successfully refactored the encoded annotation value resolution in
dalvikExecutableParser.tsto use type information parsed inencodedValueParserinstead of checking annotation types with if statements.Changes Made
Created discriminated union with typed indices:
DalvikExecutableTaggedEncodedValueis now a discriminated union withtypeproperty (literal types like'byte','short','string', etc.){ type: 'xxx' as const, value }patternas constensures TypeScript correctly infers literal types for discriminated uniontypedNumbers.ts:methodType→IndexIntoPrototypeIdsstring→IndexIntoStringIdstype→IndexIntoTypeIdsfield→IndexIntoFieldIdsmethod→IndexIntoMethodIdsenum→IndexIntoFieldIdsisoIndexInto*wrappersresolveAnnotationElementsfunction)DalvikExecutableTaggedEncodedValueto follow naming conventionUpdated DalvikExecutableEncodedValue type:
DalvikExecutableEncodedValuetype to includebigint,boolean, andnullbigintwithout precision lossbooleanpreserving semantic meaningnullinstead ofundefinednumberImproved resolution functions:
methodType→prototypes.at(),field→fields.at(), etc.)undefinedinstead of throwingmethodHandlefrom primitive types with explicit commentBenefits
DalvikExecutable*naming conventionTesting & Verification
✅ All 129 tests passing (100% pass rate)
✅ Dalvik executable parser tests passing
✅ Smali comparison tests passing
✅ Build successful
✅ Type safety improved with discriminated unions, inline object creation, and typed indices
Fixes Remove if's for encoded annotation value resolution, pass type parsed in encodedValueParser and use it to resolve encoded values #63
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.