private void RootMethods(TypeDesc type, string reason, IRootingServiceProvider rootProvider) { foreach (MethodDesc method in type.GetMethods()) { // Skip methods with no IL and uninstantiated generic methods if (method.IsIntrinsic || method.IsAbstract || method.HasInstantiation) continue; if (method.IsInternalCall) continue; try { CheckCanGenerateMethod(method); rootProvider.AddCompilationRoot(method, reason); } catch (TypeSystemException) { // TODO: fail compilation if a switch was passed // Individual methods can fail to load types referenced in their signatures. // Skip them in library mode since they're not going to be callable. continue; // TODO: Log as a warning } } }
public override IEnumerable<MethodDesc> ComputeAllVirtualMethods(TypeDesc type) { foreach (var method in type.GetMethods()) { if (method.IsVirtual) yield return method; } }
private void RootMethods(TypeDesc type, string reason, IRootingServiceProvider rootProvider) { foreach (MethodDesc method in type.GetMethods()) { // Skip methods with no IL and uninstantiated generic methods if (method.IsIntrinsic || method.IsAbstract || method.ContainsGenericVariables) continue; if (method.IsInternalCall) continue; rootProvider.AddCompilationRoot(method, reason); } }
/// <summary> /// Get the MethodDesc that corresponds to an interface type/slot pair /// </summary> public static bool TryGetMethodFromInterfaceSlot(TypeDesc owningType, ushort slot, out MethodDesc method) { int iMethod = -1; method = null; // This is only valid to call on an interface if (!owningType.IsInterface) return false; // Slots on generic interface types are off by one. if (owningType.IsGeneric()) { if (slot == 0) throw new BadImageFormatException(); slot--; } foreach (MethodDesc searchMethod in owningType.GetMethods()) { if (searchMethod.IsVirtual) { iMethod++; if (iMethod == slot) { method = searchMethod; return true; } } } return false; }
protected internal virtual IEnumerable <MethodDesc> GetAllMethods(TypeDesc type) { return(type.GetMethods()); }
protected virtual IEnumerable <MethodDesc> GetAllMethodsForValueType(TypeDesc valueType, bool virtualOnly) { TypeDesc valueTypeDefinition = valueType.GetTypeDefinition(); if (RequiresGetFieldHelperMethod((MetadataType)valueTypeDefinition)) { MethodDesc getFieldHelperMethod = _valueTypeMethodHashtable.GetOrCreateValue((DefType)valueTypeDefinition); if (valueType != valueTypeDefinition) { yield return(GetMethodForInstantiatedType(getFieldHelperMethod, (InstantiatedType)valueType)); } else { yield return(getFieldHelperMethod); } } IEnumerable <MethodDesc> metadataMethods = virtualOnly ? valueType.GetVirtualMethods() : valueType.GetMethods(); foreach (MethodDesc method in metadataMethods) { yield return(method); } }