private void ExtractGenericMethodParameters(AnalysisNet.Types.MethodDefinition method, Cecil.MethodDefinition methoddef) { foreach (Cecil.GenericParameter cecilParam in methoddef.GenericParameters) { AnalysisNet.Types.GenericParameter analysisNetParam = new AnalysisNet.Types.GenericParameter(AnalysisNet.Types.GenericParameterKind.Method, (ushort)cecilParam.Position, cecilParam.Name, GetGenericParameterTypeKind(cecilParam)) { GenericContainer = method }; method.GenericParameters.Add(analysisNetParam); ExtractCustomAttributes(analysisNetParam.Attributes, cecilParam.CustomAttributes); IEnumerable <AnalysisNet.Types.IType> constraints = cecilParam.Constraints.Select(cecilConst => ExtractType(cecilConst.ConstraintType)); analysisNetParam.Constraints.AddRange(constraints); } }
private void ExtractGenericTypeParameters(AnalysisNet.Types.IGenericDefinition definingType, Cecil.TypeDefinition typedef) { for (int i = 0; i < typedef.GenericParameters.Count; ++i) { Cecil.GenericParameter parameterdef = typedef.GenericParameters[i]; ushort index = (ushort)i; string name = parameterdef.Name; AnalysisNet.Types.TypeKind typeKind = GetGenericParameterTypeKind(parameterdef); AnalysisNet.Types.GenericParameter parameter = new AnalysisNet.Types.GenericParameter(AnalysisNet.Types.GenericParameterKind.Type, index, name, typeKind); ExtractCustomAttributes(parameter.Attributes, parameterdef.CustomAttributes); parameter.GenericContainer = definingType; definingType.GenericParameters.Add(parameter); parameter.Constraints.AddRange(parameterdef.Constraints.Select(c => ExtractType(c.ConstraintType))); } }