예제 #1
0
 public static bool AssignsParameterUsingKnownExpression(this TwoFerSolution twoFerSolution) =>
 twoFerSolution.AssignsParameterUsingNullCoalescingOperator() ||
 twoFerSolution.AssignsParameterUsingNullCheck() ||
 twoFerSolution.AssignsParameterUsingIfNullCheck() ||
 twoFerSolution.AssignsParameterUsingIsNullOrEmptyCheck() ||
 twoFerSolution.AssignsParameterUsingIfIsNullOrEmptyCheck() ||
 twoFerSolution.AssignsParameterUsingIsNullOrWhiteSpaceCheck() ||
 twoFerSolution.AssignsParameterUsingIfIsNullOrWhiteSpaceCheck();
예제 #2
0
        private static SolutionAnalysis AnalyzeParameterAssignment(this TwoFerSolution twoFerSolution)
        {
            if (!twoFerSolution.AssignsToParameter())
            {
                return(null);
            }

            if (!twoFerSolution.AssignsParameterUsingKnownExpression())
            {
                return(twoFerSolution.ReferToMentor());
            }

            if (twoFerSolution.ReturnsStringFormat())
            {
                return(twoFerSolution.ApproveWithComment(UseStringInterpolationNotStringFormat));
            }

            if (twoFerSolution.ReturnsStringConcatenation())
            {
                return(twoFerSolution.ApproveWithComment(UseStringInterpolationNotStringConcatenation));
            }

            if (!twoFerSolution.ReturnsStringInterpolation())
            {
                return(null);
            }

            if (twoFerSolution.AssignsParameterUsingNullCoalescingOperator())
            {
                return(twoFerSolution.ApproveWithComment(InlineVariable));
            }

            if (twoFerSolution.AssignsParameterUsingNullCheck() ||
                twoFerSolution.AssignsParameterUsingIfNullCheck())
            {
                return(twoFerSolution.ApproveWithComment(UseNullCoalescingOperatorNotNullCheck));
            }

            if (twoFerSolution.AssignsParameterUsingIsNullOrEmptyCheck() ||
                twoFerSolution.AssignsParameterUsingIfIsNullOrEmptyCheck())
            {
                return(twoFerSolution.ApproveWithComment(UseNullCoalescingOperatorNotIsNullOrEmptyCheck));
            }

            if (twoFerSolution.AssignsParameterUsingIsNullOrWhiteSpaceCheck() ||
                twoFerSolution.AssignsParameterUsingIfIsNullOrWhiteSpaceCheck())
            {
                return(twoFerSolution.ApproveWithComment(UseNullCoalescingOperatorNotIsNullOrWhiteSpaceCheck));
            }

            return(null);
        }