/// <summary>
            /// Fully analyzes the specified <paramref name="symbol"/>.
            /// </summary>
            /// <param name="diagnosticReceiver">
            /// <see cref="IDiagnosticReceiver"/> that is used to report <see cref="Diagnostic"/> s.
            /// </param>
            /// <param name="symbol"><see cref="INamedTypeSymbol"/> to analyze.</param>
            /// <param name="compilation">Current <see cref="DefaultParamCompilationData"/>.</param>
            /// <param name="cancellationToken">
            /// <see cref="CancellationToken"/> that specifies if the operation should be canceled.
            /// </param>
            /// <returns>
            /// <see langword="true"/> if the <paramref name="symbol"/> is valid, otherwise <see langword="false"/>.
            /// </returns>
            public static bool Analyze(
                IDiagnosticReceiver diagnosticReceiver,
                INamedTypeSymbol symbol,
                DefaultParamCompilationData compilation,
                CancellationToken cancellationToken = default
                )
            {
                TypeParameterContainer typeParameters = TypeParameterContainer.CreateFrom(symbol, compilation, cancellationToken);

                if (!typeParameters.HasDefaultParams)
                {
                    return(false);
                }

                bool isValid = AnalyzeAgainstProhibitedAttributes(diagnosticReceiver, symbol, compilation, out AttributeData[]? attributes);

                isValid &= AnalyzeContainingTypes(diagnosticReceiver, symbol, compilation, out INamedTypeSymbol[]? containingTypes, cancellationToken);
                isValid &= AnalyzeTypeParameters(diagnosticReceiver, symbol, in typeParameters);

                if (isValid)
                {
                    string targetNamespace = GetTargetNamespace(symbol, compilation, attributes !, containingTypes !);

                    return(AnalyzeCollidingMembers(diagnosticReceiver, symbol, in typeParameters, compilation, targetNamespace, out _, attributes !, containingTypes !, cancellationToken));
                }

                return(false);
            }
コード例 #2
0
            /// <inheritdoc cref="DefaultParamDelegateAnalyzer.WithDiagnostics.Analyze(IDiagnosticReceiver, INamedTypeSymbol, DefaultParamCompilationData, CancellationToken)"/>
            public static bool Analyze(
                IDiagnosticReceiver diagnosticReceiver,
                INamedTypeSymbol symbol,
                DefaultParamCompilationData compilation,
                CancellationToken cancellationToken = default
                )
            {
                TypeParameterContainer typeParameters = TypeParameterContainer.CreateFrom(symbol, compilation, cancellationToken);

                if (!typeParameters.HasDefaultParams)
                {
                    return(false);
                }

                ImmutableArray <AttributeData> attributes = symbol.GetAttributes();

                INamedTypeSymbol[] containingTypes = symbol.GetContainingTypeSymbols().ToArray();

                bool isValid = AnalyzeAgainstProhibitedAttributes(diagnosticReceiver, symbol, compilation, attributes);

                isValid &= AnalyzeContainingTypes(diagnosticReceiver, symbol, compilation, containingTypes, cancellationToken);
                isValid &= AnalyzeAgainstPartial(diagnosticReceiver, symbol, cancellationToken);
                isValid &= AnalyzeTypeParameters(diagnosticReceiver, symbol, in typeParameters);

                if (isValid)
                {
                    string targetNamespace = GetTargetNamespace(symbol, compilation, attributes, containingTypes);

                    isValid &= AnalyzeCollidingMembers(diagnosticReceiver, symbol, in typeParameters, compilation, targetNamespace, out _, attributes, containingTypes, cancellationToken);
                }

                ShouldInheritInsteadOfCopying(diagnosticReceiver, symbol, compilation, attributes, containingTypes);

                return(isValid);
            }
コード例 #3
0
        /// <summary>
        /// Fully analyzes the specified <paramref name="symbol"/>.
        /// </summary>
        /// <param name="symbol"><see cref="INamedTypeSymbol"/> to analyze.</param>
        /// <param name="compilation">Current <see cref="DefaultParamCompilationData"/>.</param>
        /// <param name="cancellationToken"><see cref="CancellationToken"/> that specifies if the operation should be canceled.</param>
        /// <returns><see langword="true"/> if the <paramref name="symbol"/> is valid, otherwise <see langword="false"/>.</returns>
        public static bool Analyze(
            INamedTypeSymbol symbol,
            DefaultParamCompilationData compilation,
            CancellationToken cancellationToken = default
            )
        {
            TypeParameterContainer typeParameters = TypeParameterContainer.CreateFrom(symbol, compilation, cancellationToken);

            if (!typeParameters.HasDefaultParams)
            {
                return(false);
            }

            if (AnalyzeAgainstProhibitedAttributes(symbol, compilation, out AttributeData[]? attributes) &&
コード例 #4
0
        /// <summary>
        /// Fully analyzes the specified <paramref name="symbol"/>.
        /// </summary>
        /// <param name="symbol"><see cref="IMethodSymbol"/> to analyze.</param>
        /// <param name="compilation">Current <see cref="DefaultParamCompilationData"/>.</param>
        /// <param name="cancellationToken"><see cref="CancellationToken"/> that specifies if the operation should be canceled.</param>
        /// <returns><see langword="true"/> if the <paramref name="symbol"/> is valid, otherwise <see langword="false"/>.</returns>
        public static bool Analyze(
            IMethodSymbol symbol,
            DefaultParamCompilationData compilation,
            CancellationToken cancellationToken = default
            )
        {
            TypeParameterContainer typeParameters = TypeParameterContainer.CreateFrom(symbol, compilation, cancellationToken);

            if (!typeParameters.HasDefaultParams && !symbol.IsOverride)
            {
                return(false);
            }

            return(AnalyzeCore(symbol, compilation, ref typeParameters, cancellationToken));
        }