Ejemplo n.º 1
0
        public static SyntaxTrivia DetermineEndOfLine(SyntaxToken token, SyntaxTrivia?defaultValue = null)
        {
            SyntaxTrivia trivia = FindEndOfLine(token);

            return((trivia.IsEndOfLineTrivia())
                ? trivia
                : defaultValue ?? CSharpFactory.NewLine());
        }
Ejemplo n.º 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()));
        }
Ejemplo n.º 3
0
        public static SyntaxTrivia GetEndOfLine(SyntaxToken token)
        {
            SyntaxTrivia trivia = FindEndOfLine(token);

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