GenParamCount is the number of generic parameters for the method.
So the ulArgCount here should be the # of parameters. And ulArgIx = 0 is the RetType, so [1, ulArgCount] will be the actual args. That means the condition in the if statement should be ulArgIx <= ulArgCount instead of <.
I did some debugging by debugger, it did forget to validate the last arg. If it is necessary, I might create an invalid dll that will not be detected by this piece of code.
I was reading the CLR source code these days to learn better of dotnet. The following code seems to be a bug to me. https://github.com/dotnet/runtime/blob/5535e31a712343a63f5d7d796cd874e563e5ac14/src/coreclr/utilcode/util.cpp#L1894-L1905 According to the ECMA spec:
So the
ulArgCount
here should be the # of parameters. AndulArgIx = 0
is theRetType
, so[1, ulArgCount]
will be the actual args. That means the condition in the if statement should beulArgIx <= ulArgCount
instead of<
.I did some debugging by debugger, it did forget to validate the last arg. If it is necessary, I might create an invalid dll that will not be detected by this piece of code.