// first-pass looks at each public BeginFoo or EndFoo method and makes it private. // for methods that are interface implementations, we need to remember them so that we can update // the calling code in the second pass private bool MapMethodFirstPass(CodeMemberMethod method) { if (method != null && (CodeDomHelpers.IsBeginMethod(method) || CodeDomHelpers.IsEndMethod(method)) && IsPublic(method.Attributes)) { if (method.ImplementationTypes.Count == 0) { // doesn't impl an iface method, just make it private, and remember it for the second pass method.Attributes = MakePrivate(method.Attributes); // clobber existing entries -- non iface-methods take precedence _privateIfaceMethods[method.Name] = new PrivateInterfaceMethod(null); } else { // impls an iface method, make it a private impl, and remember it for the second pass CodeTypeReference ifaceType = method.ImplementationTypes[0]; method.ImplementationTypes.Clear(); method.PrivateImplementationType = ifaceType; if (!_privateIfaceMethods.ContainsKey(method.Name)) { // only add it if it wasn't already there -- non-iface methods take precedence _privateIfaceMethods.Add(method.Name, new PrivateInterfaceMethod(ifaceType)); } } } return(true); // don't remove }
protected override void VisitAttributedType(CodeTypeDeclaration type) { base.VisitAttributedType(type); CollectionHelpers.MapList <CodeMemberMethod>( type.Members, delegate(CodeMemberMethod method) { return(CodeDomHelpers.IsBeginMethod(method) || CodeDomHelpers.IsTaskAsyncMethod(method) || CodeDomHelpers.IsEndMethod(method)); }, this.CopyAttrsToTaskAsyncMethod ); }
protected override void VisitClientClass(CodeTypeDeclaration type) { base.VisitClientClass(type); CollectionHelpers.MapList <CodeMemberMethod>( type.Members, delegate(CodeMemberMethod method) { return(method is CodeConstructor || CodeDomHelpers.IsBeginMethod(method) || CodeDomHelpers.IsEndMethod(method) || CodeDomHelpers.IsTaskAsyncMethod(method)); }, null ); }