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

Code before:
                ValidateSafetyOfUsingTypeEquivalenceOfType(type);
            }
        }

        void ValidateSafetyOfUsingTypeEquivalenceOfType(TypeDesc type)
        {
            if (type.IsValueType && type.IsTypeDefEquivalent && !_compilation.CompilationModuleGroup.VersionsWithTypeReference(type))
            {
                // Technically this is a bit pickier than needed, as cross module inlineable cases will be hit by this, but type equivalence is a
                // rarely used feature, and we can fix that if we need to.
                throw new RequiresRuntimeJitException($"Type equivalent valuetype '{type}' not directly referenced from member reference");
            }
        }

        private bool notifyMethodInfoUsage(CORINFO_METHOD_STRUCT_* ftn)
        {
            MethodDesc method = HandleToObject(ftn);
            Debug.Assert(method != null);
            // If ftn isn't within the current version bubble we can't rely on methodInfo being
            // stable e.g. mark calls as no-return if their IL has no rets.
            return _compilation.NodeFactory.CompilationModuleGroup.VersionsWithMethodBody(method);
        }

        private CORINFO_WASM_TYPE_SYMBOL_STRUCT_* getWasmTypeSymbol(CorInfoWasmType* types, UIntPtr typesSize)
        {
            CorInfoWasmType[] typeArray = new CorInfoWasmType[(int)typesSize.ToUInt32()];
            for (int i = 0; i < typeArray.Length; i++)
            {
                typeArray[i] = types[i];
            }
            WasmTypeNode typeNode = _compilation.NodeFactory.WasmTypeNode(typeArray);
            return (CORINFO_WASM_TYPE_SYMBOL_STRUCT_*)ObjectToHandle(typeNode);
        }

#pragma warning disable CA1822 // Mark members as static
        private void getThreadLocalStaticInfo_NativeAOT(CORINFO_THREAD_STATIC_INFO_NATIVEAOT* pInfo)
        {
            // Implemented for NativeAOT only for now.
        }
#pragma warning restore CA1822 // Mark members as static
    }
}


Review comment (suggestion):
```suggestion
        private CORINFO_WASM_TYPE_SYMBOL_STRUCT_* getWasmTypeSymbol(CorInfoWasmType* types, nuint typesSize)
        {
            CorInfoWasmType[] typeArray = new CorInfoWasmType[(int)typesSize];
```

Code after:
                ValidateSafetyOfUsingTypeEquivalenceOfType(type);
            }
        }

        void ValidateSafetyOfUsingTypeEquivalenceOfType(TypeDesc type)
        {
            if (type.IsValueType && type.IsTypeDefEquivalent && !_compilation.CompilationModuleGroup.VersionsWithTypeReference(type))
            {
                // Technically this is a bit pickier than needed, as cross module inlineable cases will be hit by this, but type equivalence is a
                // rarely used feature, and we can fix that if we need to.
                throw new RequiresRuntimeJitException($"Type equivalent valuetype '{type}' not directly referenced from member reference");
            }
        }

        private bool notifyMethodInfoUsage(CORINFO_METHOD_STRUCT_* ftn)
        {
            MethodDesc method = HandleToObject(ftn);
            Debug.Assert(method != null);
            // If ftn isn't within the current version bubble we can't rely on methodInfo being
            // stable e.g. mark calls as no-return if their IL has no rets.
            return _compilation.NodeFactory.CompilationModuleGroup.VersionsWithMethodBody(method);
        }

        private CORINFO_WASM_TYPE_SYMBOL_STRUCT_* getWasmTypeSymbol(CorInfoWasmType* types, nuint typesSize)
        {
            CorInfoWasmType[] typeArray = new ReadOnlySpan<CorInfoWasmType>(types, (int)typesSize).ToArray();
            WasmTypeNode typeNode = _compilation.NodeFactory.WasmTypeNode(typeArray);
            return (CORINFO_WASM_TYPE_SYMBOL_STRUCT_*)ObjectToHandle(typeNode);
        }

#pragma warning disable CA1822 // Mark members as static
        private void getThreadLocalStaticInfo_NativeAOT(CORINFO_THREAD_STATIC_INFO_NATIVEAOT* pInfo)
        {
            // Implemented for NativeAOT only for now.
        }
#pragma warning restore CA1822 // Mark members as static
    }
}