Skip to content

Implement analysis context for method parameters #95

@SamboyCoding

Description

@SamboyCoding

Method parameters can and often do have custom attributes. Most notably, System.ParamArrayAttribute indicates that an array parameter is actually params, meaning no explicit array construction is required from the caller side, but also Jetbrains nullability attributes, optional attributes, etc. could be present. At the moment, both the legacy new-analysis branch of Cpp2IL and the rewrite have no support for reading CAs on parameters.

Getting the custom attribute data should be simple - like other members with custom attributes, a simple binary search for the token is sufficient, or on v24 a simple indexed lookup - however a rework of the data structure will likely be required in order to add a ParameterAnalysisContext, as well as a rework of the DummyDLL output format to actually use it.

While we're creating analysis contexts for these, adding some sort of specifier to determine what register the parameter starts in could be useful, as all ApplicationAnalysisContext objects have an InstructionSet.

Equally, the data for parameters is somewhat fragmented - the default value, if present, is dependent on the absolute index of the parameter in the metadata array, the parameter type is separate, etc, so caching these in the context could be useful, though whether these are best exposed as raw libcpp2il types or something else is worth discussion. At the very least, they should be added as (cache-backed) getters to the parameter definition.

Finally, the ability to inject parameters must be maintained (and this is a good opportunity to allow for named injected parameters)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions