For some library debugging usage I am developing a custom attribute which would be able to match existing methods.
For example the following:
[NetMethodAliasMethod("TryParse", Parameters = new Type[] { typeof(string), typeof(char)})]
...should match static bool System.Char.TryParse (string? s, out char result). The attribute "Parameters" are tested against ParameterInfo.ParameterType MethodInfo.GetParameters() to match the parameters (of course name is matched as well).
In case of the string? this works because the nullable attribute is not part of the type. However the type returned from MethodInfo for the 2nd parameter is char&, while typeof(char&) is not allowed. Is there any possible way to pass this type ?
I was thinking about generic delegates, but see no way as the use of delegates is to be specific on which methods are compatible. Another Idea was to use typeof(System.Char).GetMethod("TryParse"). But this causes the same trouble if multiple overloads exist, where we would have to use GetMethods (with 's') instead and again match the parameter types.
Of course I could use string checking of the type names, but that should be the last resort if no other way is possible. But since Type(char&) exists, I hope there is a way to get it ?