private void AddDelegateMembers( ArrayBuilder<Symbol> symbols, DelegateDeclarationSyntax syntax, BinderFactory binderFactory, DiagnosticBag diagnostics) { var bodyBinder = binderFactory.GetBinder(syntax.ParameterList); // A delegate has the following members: (see CLI spec 13.6) // (1) a method named Invoke with the specified signature var invoke = new DelegateInvokeMethodImplementation(this, syntax, bodyBinder, diagnostics); invoke.CheckMethodVarianceSafety(diagnostics); symbols.Add(invoke); // (2) a constructor with argument types (object, System.IntPtr) symbols.Add(new DelegateConstructor(this, syntax, bodyBinder)); var delegateBinder = new DelegateBinder(bodyBinder, this, invoke); // (3) BeginInvoke symbols.Add(new DelegateBeginInvokeMethod(this, syntax, delegateBinder, diagnostics)); // and (4) EndInvoke methods symbols.Add(new DelegateEndInvokeMethod(this, syntax, delegateBinder, diagnostics)); if (this.DeclaredAccessibility <= Accessibility.Private) { return; } if (!this.IsNoMoreVisibleThan(invoke.ReturnType)) { // Inconsistent accessibility: return type '{1}' is less accessible than delegate '{0}' diagnostics.Add(ErrorCode.ERR_BadVisDelegateReturn, Locations[0], this, invoke.ReturnType); } foreach (var parameter in invoke.Parameters) { if (!parameter.Type.IsAtLeastAsVisibleAs(this)) { // Inconsistent accessibility: parameter type '{1}' is less accessible than delegate '{0}' diagnostics.Add(ErrorCode.ERR_BadVisDelegateParam, Locations[0], this, parameter.Type); } } }
private void AddDelegateMembers( ArrayBuilder <Symbol> symbols, DelegateDeclarationSyntax syntax, BinderFactory binderFactory, DiagnosticBag diagnostics) { var bodyBinder = binderFactory.GetBinder(syntax.ParameterList); // A delegate has the following members: (see CLI spec 13.6) // (1) a method named Invoke with the specified signature var invoke = new DelegateInvokeMethodImplementation(this, syntax, bodyBinder, diagnostics); invoke.CheckMethodVarianceSafety(diagnostics); symbols.Add(invoke); // (2) a constructor with argument types (object, System.IntPtr) symbols.Add(new DelegateConstructor(this, syntax, bodyBinder)); var delegateBinder = new DelegateBinder(bodyBinder, this, invoke); // (3) BeginInvoke symbols.Add(new DelegateBeginInvokeMethod(this, syntax, delegateBinder, diagnostics)); // and (4) EndInvoke methods symbols.Add(new DelegateEndInvokeMethod(this, syntax, delegateBinder, diagnostics)); if (this.DeclaredAccessibility <= Accessibility.Private) { return; } if (!this.IsNoMoreVisibleThan(invoke.ReturnType)) { // Inconsistent accessibility: return type '{1}' is less accessible than delegate '{0}' diagnostics.Add(ErrorCode.ERR_BadVisDelegateReturn, Locations[0], this, invoke.ReturnType); } foreach (var parameter in invoke.Parameters) { if (!parameter.Type.IsAtLeastAsVisibleAs(this)) { // Inconsistent accessibility: parameter type '{1}' is less accessible than delegate '{0}' diagnostics.Add(ErrorCode.ERR_BadVisDelegateParam, Locations[0], this, parameter.Type); } } }