private void OnTwinMethod(ref Method method) { Method twin; if (!_twinMethods.TryGetValue(method, out twin)) { if (method.HasAttribute(Essentials.DotNetOverrideAttribute) && method.DeclaringType.HasAttribute(Essentials.DotNetTypeAttribute)) { if (method.IsGenericParameterization) { var def = method.GenericDefinition; OnTwinMethod(ref def); twin = ILFactory.Parameterize(method.Source, def, method.GenericArguments); } else { var twinClass = GetOrCreateTwinClass(method.DeclaringType); if (method.IsGenericDefinition) { var generic = new ClassType(method.Source, twinClass, method.DocComment, Modifiers.Private | Modifiers.Static | Modifiers.Generated, method.UnoName); generic.MakeGenericDefinition(method.GenericParameters); twin = new Method(method.Source, twinClass, method.DocComment, method.Modifiers, method.Name, generic, method.ReturnType, method.Parameters, method.Body); generic.Methods.Add(twin); } else { twin = new Method(method.Source, twinClass, method.DocComment, method.Modifiers, method.Name, method.ReturnType, method.Parameters, method.Body); } twin.Stats |= method.Stats & EntityStats.ImplicitReturn; twin.SetPrototype(method); twinClass.Methods.Add(twin); } } _twinMethods.Add(method, twin); } if (twin != null) { method = twin; } }