public override void VisitCustomEventDeclaration(CustomEventDeclaration eventDeclaration)
 {
     currentMember = eventDeclaration.GetSymbol() as IMember;
     if (currentMember == null)
     {
         return;
     }
     SetContext();
     base.VisitCustomEventDeclaration(eventDeclaration);
     currentMember = null;
 }
        EventDeclaration TransformAutomaticEvents(CustomEventDeclaration ev)
        {
            if (!ev.PrivateImplementationType.IsNull)
            {
                return(null);
            }
            if (!ev.Modifiers.HasFlag(Modifiers.Abstract))
            {
                if (!CheckAutomaticEventV4(ev) && !CheckAutomaticEventV2(ev) && !CheckAutomaticEventV4MCS(ev))
                {
                    return(null);
                }
            }
            RemoveCompilerGeneratedAttribute(ev.AddAccessor.Attributes, attributeTypesToRemoveFromAutoEvents);
            EventDeclaration ed = new EventDeclaration();

            ev.Attributes.MoveTo(ed.Attributes);
            foreach (var attr in ev.AddAccessor.Attributes)
            {
                attr.AttributeTarget = "method";
                ed.Attributes.Add(attr.Detach());
            }
            ed.ReturnType = ev.ReturnType.Detach();
            ed.Modifiers  = ev.Modifiers;
            ed.Variables.Add(new VariableInitializer(ev.Name));
            ed.CopyAnnotationsFrom(ev);

            IEvent eventDef = ev.GetSymbol() as IEvent;

            if (eventDef != null)
            {
                IField field = eventDef.DeclaringType.GetFields(f => f.Name == ev.Name, GetMemberOptions.IgnoreInheritedMembers).SingleOrDefault();
                if (field != null)
                {
                    ed.AddAnnotation(field);
                    var attributes = field.GetAttributes()
                                     .Where(a => !attributeTypesToRemoveFromAutoEvents.Contains(a.AttributeType.FullName))
                                     .Select(context.TypeSystemAstBuilder.ConvertAttribute).ToArray();
                    if (attributes.Length > 0)
                    {
                        var section = new AttributeSection {
                            AttributeTarget = "field"
                        };
                        section.Attributes.AddRange(attributes);
                        ed.Attributes.Add(section);
                    }
                }
            }

            ev.ReplaceWith(ed);
            return(ed);
        }