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

Accessor rework #59

Open
2 of 16 tasks
jjvanzon opened this issue Aug 22, 2021 · 0 comments
Open
2 of 16 tasks

Accessor rework #59

jjvanzon opened this issue Aug 22, 2021 · 0 comments
Labels

Comments

@jjvanzon
Copy link
Owner

jjvanzon commented Aug 22, 2021

2021-05-31

From JJ.Framework.Reflection. Might split up in multiple tasks in the future. Some things may already be done.

  • Added a sort of disclaimer to the README.MD of JJ.Framework.Reflection for Accessor's missing features.
  • Adding InvokeMethod overloads with type arguments?
  • ~ Base type parameter matching:
    • ~ ReflectionCache.GetMethod_MatchingArgumentBaseTypes + using it in Accessor.InvokeMethod? Possibly by iterating through base types.
  • ~ Are the ByRef parameter-related Accessor methods uniform in interfacing to the other methods?
  • ~ Adding InvokeMethods overloads (with ByRef's) without type arguments?
    • Not sure. Perhaps ByRef also requires a specific type, not object.
  • ~ Is there an option to invoke methods with ByRef arguments for more than 4 arguments? Would such an option be created, by having overloads that take Type[] next to already present the overloads that take a set of type arguments?
  • ~ May any member be callable now using Accessor?
  • ~ Might methods with type arguments and ref parameters not be supported yet now?
public class Accessor
{
    // Try something with tuples.

    public object InvokeMethod(string name, params (Type type, object value)[] parameterTypesAndValues)
    {
        if (parameterTypesAndValues == null) throw new ArgumentNullException(nameof(parameterTypesAndValues));

        Type[] parameterTypes = parameterTypesAndValues.Select(x => x.type).ToArray();
        object[] parameterValues = parameterTypesAndValues.Select(x => x.value).ToArray();

        MethodInfo method = StaticReflectionCache.GetMethod(_objectType, name, parameterTypes);
    }
}
  • ~ Are non-public constructors usable?
  • ~ Overload that takes constructor parameters, only takes string typeName, not Type.
  • ~ Those might be related. Assumed internal classes with constructors, not public classes with internal constructors.
  • ~ Accessor.InvokeMethod could be improved:
    • ~ The nameExpression seems less relevant now that there is the nameof operator.
    • ~ The nameExpression might be replaced by just an expression, from which the parameter values are read out using ExpressionHelper.GetMethodCallInfo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant