Beispiel #1
0
        public static SyntaxTrivia DetermineEndOfLine(SyntaxToken token, SyntaxTrivia?defaultValue = null)
        {
            SyntaxTrivia trivia = FindEndOfLine(token);

            return((trivia.IsEndOfLineTrivia())
                ? trivia
                : defaultValue ?? CSharpFactory.NewLine());
        }
Beispiel #2
0
        public static BinaryExpressionSyntax CreateCoalesceExpression(
            ITypeSymbol targetType,
            ExpressionSyntax left,
            ExpressionSyntax right,
            int position,
            SemanticModel semanticModel)
        {
            if (targetType?.SupportsExplicitDeclaration() == true)
            {
                right = CastExpression(
                    targetType.ToMinimalTypeSyntax(semanticModel, position),
                    right.Parenthesize()).WithSimplifierAnnotation();
            }

            return(CSharpFactory.CoalesceExpression(
                       left.Parenthesize(),
                       right.Parenthesize()));
        }
        public static SyntaxTrivia GetEndOfLine(SyntaxToken token)
        {
            SyntaxTrivia trivia = FindEndOfLine(token);

            return((trivia.IsEndOfLineTrivia()) ? trivia : CSharpFactory.NewLine());
        }