private void ComputeParameters() { if (_lazyParameters != null) { return; } SyntaxToken arglistToken; var diagnostics = BindingDiagnosticBag.GetInstance(_declarationDiagnostics); var parameters = ParameterHelpers.MakeParameters( _binder, this, this.Syntax.ParameterList, arglistToken: out arglistToken, allowRefOrOut: true, allowThis: true, addRefReadOnlyModifier: false, diagnostics: diagnostics); var compilation = DeclaringCompilation; ParameterHelpers.EnsureIsReadOnlyAttributeExists(compilation, parameters, diagnostics, modifyCompilation: false); ParameterHelpers.EnsureNativeIntegerAttributeExists(compilation, parameters, diagnostics, modifyCompilation: false); ParameterHelpers.EnsureNullableAttributeExists(compilation, this, parameters, diagnostics, modifyCompilation: false); foreach (var parameter in parameters) { ParameterHelpers.ReportParameterNullCheckingErrors(diagnostics.DiagnosticBag, parameter); } // Note: we don't need to warn on annotations used in #nullable disable context for local functions, as this is handled in binding already var isVararg = arglistToken.Kind() == SyntaxKind.ArgListKeyword; if (isVararg) { diagnostics.Add(ErrorCode.ERR_IllegalVarArgs, arglistToken.GetLocation()); } lock (_declarationDiagnostics) { if (_lazyParameters != null) { diagnostics.Free(); return; } _declarationDiagnostics.AddRangeAndFree(diagnostics); _lazyIsVarArg = isVararg; _lazyParameters = parameters; } }
internal void GetDeclarationDiagnostics(BindingDiagnosticBag addTo) { // Force complete type parameters foreach (var typeParam in _typeParameters) { typeParam.ForceComplete(null, default(CancellationToken)); } // force lazy init ComputeParameters(); foreach (var p in _lazyParameters) { // Force complete parameters to retrieve all diagnostics p.ForceComplete(null, default(CancellationToken)); } ComputeReturnType(); GetAttributes(); GetReturnTypeAttributes(); AsyncMethodChecks(_declarationDiagnostics); addTo.AddRange(_declarationDiagnostics, allowMismatchInDependencyAccumulation: true); var diagnostics = BindingDiagnosticBag.GetInstance( withDiagnostics: false, withDependencies: addTo.AccumulatesDependencies ); if ( IsEntryPointCandidate && !IsGenericMethod && ContainingSymbol is SynthesizedSimpleProgramEntryPointSymbol && DeclaringCompilation.HasEntryPointSignature(this, diagnostics).IsCandidate ) { addTo.Add(ErrorCode.WRN_MainIgnored, Syntax.Identifier.GetLocation(), this); } addTo.AddRangeAndFree(diagnostics); }