Repository: dotnet/runtime
File: src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ReadyToRunMethod.cs (C#)

Code before:
                EnsureFixupCells();
                return _fixupCells;
            }
        }

        public string[] InstanceArgs { get; set; }

        public int RuntimeFunctionCount { get; set; }
        public int ColdRuntimeFunctionCount { get; set; }

        /// <summary>
        /// Extracts the method signature from the metadata by rid
        /// </summary>
        public ReadyToRunMethod(
            ReadyToRunReader readyToRunReader,
            IAssemblyMetadata componentReader,
            EntityHandle methodHandle,
            int entryPointId,
            string owningType,
            string constrainedType,
            string[] instanceArgs,
            int? fixupOffset)
        {
            InstanceArgs = (string[])instanceArgs?.Clone();
            _readyToRunReader = readyToRunReader;
            _fixupOffset = fixupOffset;
            MethodHandle = methodHandle;
            EntryPointRuntimeFunctionId = entryPointId;

            ComponentReader = componentReader;

            EntityHandle owningTypeHandle;
            GenericParameterHandleCollection genericParams = default(GenericParameterHandleCollection);

            DisassemblingGenericContext genericContext = new DisassemblingGenericContext(typeParameters: Array.Empty<string>(), methodParameters: instanceArgs);
            DisassemblingTypeProvider typeProvider = new DisassemblingTypeProvider();

            // get the method signature from the method handle
            switch (MethodHandle.Kind)
            {
                case HandleKind.MethodDefinition:
                {
                    MethodDefinition methodDef = ComponentReader.MetadataReader.GetMethodDefinition((MethodDefinitionHandle)MethodHandle);
                    if (methodDef.RelativeVirtualAddress != 0)
                    {
                        System.Diagnostics.Debug.Assert(ComponentReader.ImageReader != null, "Component should be a PE and have an associated PEReader");
                        MethodBodyBlock mbb = ComponentReader.ImageReader.GetMethodBody(methodDef.RelativeVirtualAddress);
                        if (!mbb.LocalSignature.IsNil)
                        {
                            StandaloneSignature ss = ComponentReader.MetadataReader.GetStandaloneSignature(mbb.LocalSignature);
                            LocalSignature = ss.DecodeLocalSignature(typeProvider, genericContext);

Review comment (refactor):
ReadyToRunMethod is in a packable library (ILCompiler.Reflection.ReadyToRun.Experimental) and this PR changes the public constructor signature by adding signaturePrefixes. To reduce breaking changes for source consumers, consider adding an overload that preserves the previous constructor signature and forwards to the new one (or make the new parameter optional with a default).
```suggestion
            string[] instanceArgs,
            int? fixupOffset)
            : this(
                readyToRunReader,
                componentReader,
                methodHandle,
                entryPointId,
                owningType,
                constrainedType,
                instanceArgs,
                Array.Empty<string>(),
                fixupOffset)
        {
        }

        /// <summary>
        /// Extracts the method signature from the metadata by rid
        /// </summary>
        public ReadyToRunMethod(
            ReadyToRunReader readyToRunReader,
            IAssemblyMetadata componentReader,
            EntityHandle methodHandle,
            int entryPointId,
            string owningType,
            string constrainedType,
            string[] instanceArgs,
            string[] signaturePrefixes,
            int? fixupOffset)
        {
            InstanceArgs = (string[])instanceArgs?.Clone();
            SignaturePrefixes = (string[])signaturePrefixes?.Clone();
```

Code after:
                EnsureFixupCells();
                return _fixupCells;
            }
        }

        public string[] InstanceArgs { get; set; }

        public int RuntimeFunctionCount { get; set; }
        public int ColdRuntimeFunctionCount { get; set; }
        public string[] SignaturePrefixes { get; }

        /// <summary>
        /// Extracts the method signature from the metadata by rid
        /// </summary>
        public ReadyToRunMethod(
            ReadyToRunReader readyToRunReader,
            IAssemblyMetadata componentReader,
            EntityHandle methodHandle,
            int entryPointId,
            string owningType,
            string constrainedType,
            string[] instanceArgs,
            string[] signaturePrefixes,
            int? fixupOffset)
        {
            InstanceArgs = (string[])instanceArgs?.Clone();
            _readyToRunReader = readyToRunReader;
            _fixupOffset = fixupOffset;
            MethodHandle = methodHandle;
            EntryPointRuntimeFunctionId = entryPointId;

            ComponentReader = componentReader;

            EntityHandle owningTypeHandle;
            GenericParameterHandleCollection genericParams = default(GenericParameterHandleCollection);

            DisassemblingGenericContext genericContext = new DisassemblingGenericContext(typeParameters: Array.Empty<string>(), methodParameters: instanceArgs);
            DisassemblingTypeProvider typeProvider = new DisassemblingTypeProvider();

            // get the method signature from the method handle
            switch (MethodHandle.Kind)
            {
                case HandleKind.MethodDefinition:
                {
                    MethodDefinition methodDef = ComponentReader.MetadataReader.GetMethodDefinition((MethodDefinitionHandle)MethodHandle);
                    if (methodDef.RelativeVirtualAddress != 0)
                    {
                        System.Diagnostics.Debug.Assert(ComponentReader.ImageReader != null, "Component should be a PE and have an associated PEReader");
                        MethodBodyBlock mbb = ComponentReader.ImageReader.GetMethodBody(methodDef.RelativeVirtualAddress);
                        if (!mbb.LocalSignature.IsNil)
                        {