예제 #1
0
        /// <summary>
        /// Gets or creates a method weaver for the property getter.
        /// </summary>
        /// <returns></returns>
        public MethodEmitter GetGetter()
        {
            if (getter != null)
            {
                return(getter);
            }

            var attributes = MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.Public;

            if (IsStatic)
            {
                attributes |= MethodAttributes.Static;
            }

            var method = new MethodDefinition($"get_{Target.Name}", attributes, Target.PropertyType);

            Parent.Target.Methods.Add(method);
            Target.GetMethod = method;

            Parent.Context.AddCompilerGenerated(method);

            return(getter = new MethodEmitter(Parent, method));
        }