897 references to SyntaxFacts
Microsoft.AspNetCore.App.Analyzers (1)
RouteEmbeddedLanguage\FrameworkParametersCompletionProvider.cs (1)
290return SyntaxFacts.IsPredefinedType(token.Kind()) || token.IsKind(SyntaxKind.IdentifierToken);
Microsoft.CodeAnalysis.CSharp (399)
Binder\Binder.IdentifierUsedAsValueFinder.cs (4)
76if (SyntaxFacts.IsInTypeOnlyContext(id) && 156if (SyntaxFacts.IsInTypeOnlyContext(expression) && 200enclosingBinder.LookupIdentifier(_lookupResult, id, SyntaxFacts.IsInvoked(id), ref useSiteInfo); 228invoked = SyntaxFacts.IsInvoked(memberAccess);
Binder\Binder_AnonymousTypes.cs (1)
224expressionType = CreateErrorType(SyntaxFacts.GetText(SyntaxKind.VoidKeyword));
Binder\Binder_Conversions.cs (1)
430if (SyntaxFacts.IsCheckedOperator(method.Name) &&
Binder\Binder_Crefs.cs (1)
239(isChecked && !syntax.OperatorToken.IsMissing && !SyntaxFacts.IsCheckedOperator(memberName))) // the operator cannot be checked
Binder\Binder_Expressions.cs (15)
1710Debug.Assert(SyntaxFacts.IsInvoked(id) == invoked); 2367if (SyntaxFacts.IsName(node.Kind())) 2369if (SyntaxFacts.IsNamespaceAliasQualifier(node)) 2373else if (SyntaxFacts.IsInNamespaceOrTypeContext(node)) 2378else if (SyntaxFacts.IsTypeSyntax(node.Kind())) 2383return this.BindExpression(node, diagnostics, SyntaxFacts.IsInvoked(node), SyntaxFacts.IsIndexed(node)); 6297if (SyntaxFacts.IsAssignmentExpression(elementInitializer.Kind())) 7371Debug.Assert(invoked == SyntaxFacts.IsInvoked(node)); 7628diagnostics.Add(ErrorCode.ERR_BadUnaryOp, operatorToken.GetLocation(), SyntaxFacts.GetText(operatorToken.Kind()), leftType); 7635DiagnosticInfo diagnosticInfo = new CSDiagnosticInfo(ErrorCode.ERR_BadOpOnNullOrDefaultOrNew, SyntaxFacts.GetText(operatorToken.Kind()), boundLeft.Display); 7645diagnostics.Add(ErrorCode.ERR_BadUnaryOp, node.Location, SyntaxFacts.GetText(operatorToken.Kind()), msgId.Localize()); 8553var isFixedStatementExpression = SyntaxFacts.IsFixedStatementExpression(node); 9806var name = candidate.IsIndexer ? SyntaxFacts.GetText(SyntaxKind.ThisKeyword) : candidate.Name; 11119DiagnosticInfo diagnosticInfo = new CSDiagnosticInfo(ErrorCode.ERR_BadUnaryOp, SyntaxFacts.GetText(operatorToken.Kind()), msgId.Localize());
Binder\Binder_InterpolatedString.cs (2)
131else if (SyntaxFacts.IsWhitespace(lastChar = text[text.Length - 1]) || SyntaxFacts.IsNewLine(lastChar))
Binder\Binder_Invocation.cs (1)
2334this.LookupSymbolsWithFallback(lookupResult, SyntaxFacts.GetText(SyntaxKind.NameOfKeyword), useSiteInfo: ref discardedUseSiteInfo, arity: 0, options: options);
Binder\Binder_Operators.cs (5)
2424if (SyntaxFacts.IsCheckedOperator(methodOpt.Name)) 2516bool isFixedStatementAddressOfExpression = SyntaxFacts.IsFixedStatementExpression(node); 3177Error(diagnostics, ErrorCode.ERR_BadUnaryOp, node, SyntaxFacts.GetText(SyntaxKind.IsKeyword), operand.Display); 3972Error(diagnostics, ErrorCode.ERR_BadBinaryOps, node, SyntaxFacts.GetText(node.OperatorToken.Kind()), leftOperand.Display, rightOperand.Display); 4230Error(diagnostics, ErrorCode.ERR_BadBinaryOps, node, SyntaxFacts.GetText(node.OperatorToken.Kind()), leftOperand.Display, rightOperand.Display);
Binder\Binder_QueryErrors.cs (9)
171clauseKind = SyntaxFacts.GetText(SyntaxKind.JoinKeyword); 175clauseKind = SyntaxFacts.GetText(SyntaxKind.LetKeyword); 178clauseKind = SyntaxFacts.GetText(SyntaxKind.SelectKeyword); 181clauseKind = SyntaxFacts.GetText(SyntaxKind.WhereKeyword); 186clauseKind = SyntaxFacts.GetText(SyntaxKind.OrderByKeyword); 190clauseKind = SyntaxFacts.GetText(SyntaxKind.IntoKeyword); 193clauseKind = SyntaxFacts.GetText(SyntaxKind.GroupKeyword) + " " + SyntaxFacts.GetText(SyntaxKind.ByKeyword); 201clauseKind = SyntaxFacts.GetText(SyntaxKind.FromKeyword);
Binder\Binder_Statements.cs (1)
3415bool syntacticallyValid = SyntaxFacts.IsStatementExpression(syntax);
Binder\Binder_Symbols.cs (3)
941if (SyntaxFacts.IsInTypeOnlyContext(node)) 1067if (SyntaxFacts.IsAttributeName(node)) 2564Debug.Assert(aliasOpt == null || aliasOpt == SyntaxFacts.GetText(SyntaxKind.GlobalKeyword));
Binder\BinderFactory.BinderFactoryVisitor.cs (2)
105if (SyntaxFacts.IsSimpleProgramTopLevelStatement(node)) 1448for (; !SyntaxFacts.IsDocumentationCommentTrivia(curr.Kind()); curr = curr.Parent)
Binder\Semantics\Operators\BinaryOperatorOverloadResolution.cs (1)
929if (isChecked && SyntaxFacts.IsCheckedOperator(name1))
Binder\Semantics\Operators\OperatorFacts.cs (3)
128if (SyntaxFacts.IsBinaryExpressionOperatorToken(opTokenKind)) 132SyntaxFacts.IsPrefixUnaryExpressionOperatorToken(opTokenKind) && 140else if (SyntaxFacts.IsUnaryOperatorDeclarationToken(opTokenKind))
Binder\Semantics\Operators\UnaryOperatorOverloadResolution.cs (1)
485if (isChecked && SyntaxFacts.IsCheckedOperator(name1))
Binder\Semantics\OverloadResolution\OverloadResolutionResult.cs (1)
905badParamName = SyntaxFacts.GetText(SyntaxKind.ArgListKeyword);
Binder\SwitchBinder.cs (1)
528var labelName = SyntaxFacts.GetText(node.CaseOrDefaultKeyword.Kind());
Binder\WithCrefTypeParametersBinder.cs (1)
130if (SyntaxFacts.IsValidIdentifier(name) && !map.ContainsKey(name))
CommandLine\CSharpCommandLineParser.cs (2)
1787if (SyntaxFacts.IsValidIdentifier(id)) 1927if (!SyntaxFacts.IsValidIdentifier(alias))
Compilation\AttributeSemanticModel.cs (1)
92else if (SyntaxFacts.IsAttributeName(node))
Compilation\CSharpCompilation.cs (10)
3846var b = SyntaxFacts.HexValue(bytesText[i * 2]) * 16 + 3847SyntaxFacts.HexValue(bytesText[i * 2 + 1]); 3866var b = SyntaxFacts.HexValue(bytesText[i * 2]) * 16 + 3867SyntaxFacts.HexValue(bytesText[i * 2 + 1]); 4214var syntaxKind = SyntaxFacts.GetOperatorKind(name); 4218var binaryOperatorName = OperatorFacts.BinaryOperatorNameFromSyntaxKindIfAny(syntaxKind, SyntaxFacts.IsCheckedOperator(name)); 4238var binaryKind = Binder.SyntaxKindToBinaryOperatorKind(SyntaxFacts.GetBinaryExpression(syntaxKind)); 4437var syntaxKind = SyntaxFacts.GetOperatorKind(name); 4444var unaryOperatorName = OperatorFacts.UnaryOperatorNameFromSyntaxKindIfAny(syntaxKind, SyntaxFacts.IsCheckedOperator(name)); 4462var unaryKind = Binder.SyntaxKindToUnaryOperatorKind(SyntaxFacts.GetPrefixUnaryExpression(syntaxKind));
Compilation\CSharpSemanticModel.cs (7)
121(node is ExpressionSyntax && (isSpeculative || allowNamedArgumentName || !SyntaxFacts.IsNamedArgumentName(node))) || 527else if (SyntaxFacts.IsNamedArgumentName(expression)) 532else if (SyntaxFacts.IsDeclarationExpressionType(expression, out DeclarationExpressionSyntax parent)) 958else if (SyntaxFacts.IsDeclarationExpressionType(expression, out DeclarationExpressionSyntax parent)) 1618if (parentExpr != null && !(parentExpr.Parent is XmlNameAttributeSyntax) && !SyntaxFacts.IsInTypeOnlyContext(parentExpr) && !binder.IsInsideNameof) 4468Debug.Assert(SyntaxFacts.IsNamedArgumentName(identifierNameSyntax)); 4845if (node.Ancestors().Any(n => SyntaxFacts.IsPreprocessorDirective(n.Kind())))
Compilation\SpeculativeSyntaxTreeSemanticModel.cs (1)
103if (SyntaxFacts.IsInNamespaceOrTypeContext(node))
Compilation\SyntaxTreeSemanticModel.cs (7)
223if ((object)result.Symbol == null && result.CandidateReason == CandidateReason.None && node is ExpressionSyntax && SyntaxFacts.IsInNamespaceOrTypeContext((ExpressionSyntax)node)) 345if (SyntaxFacts.IsNamespaceAliasQualifier(type)) 349else if (SyntaxFacts.IsInTypeOnlyContext(type)) 938if (SyntaxFacts.IsSimpleProgramTopLevelStatement((GlobalStatementSyntax)memberDecl)) 993if (SyntaxFacts.IsDocumentationCommentTrivia(curr.Kind())) 2316if (SyntaxFacts.IsTypeDeclaration(memberDeclaration.Kind())) 2336|| SyntaxFacts.IsTypeDeclaration(memberDeclaration.Kind()))
Compiler\DocumentationCommentCompiler.cs (3)
823if (!SyntaxFacts.IsWhitespace(str[start])) 909if (trimmedLength < 4 || !SyntaxFacts.IsWhitespace(text[trimStart + 3])) 1025if (SyntaxFacts.IsWhitespace(ch))
Compiler\MethodCompiler.cs (2)
2054if (SyntaxFacts.IsInTypeOnlyContext(expression) && 2094if (SyntaxFacts.IsInTypeOnlyContext(id) &&
Compiler\UnprocessedDocumentationCommentFinder.cs (1)
100if (!_isValidLocation && SyntaxFacts.IsDocumentationCommentTrivia(trivia.Kind()))
CSharpExtensions.cs (3)
224return SyntaxFacts.IsKeywordKind(token.Kind()); 229return SyntaxFacts.IsContextualKeyword(token.Kind()); 234return SyntaxFacts.IsReservedKeyword(token.Kind());
CSharpParseOptions.cs (1)
251else if (!SyntaxFacts.IsValidIdentifier(symbol))
Declarations\DeclarationTreeBuilder.cs (3)
168hasAwaitExpressions = SyntaxFacts.HasAwaitOperations(topLevelStatement); 173isIterator = SyntaxFacts.HasYieldOperations(topLevelStatement); 178hasReturnWithExpression = SyntaxFacts.HasReturnWithExpression(topLevelStatement);
FlowAnalysis\DefiniteAssignment.cs (1)
2700if (node.FieldSymbol.IsFixedSizeBuffer && node.Syntax != null && !SyntaxFacts.IsFixedStatementExpression(node.Syntax))
Lowering\ClosureConversion\ExpressionLambdaRewriter.cs (3)
483return isChecked || (methodOpt is { Name: string name } && SyntaxFacts.IsCheckedOperator(name)); 711var e2 = _bound.StaticCall(node.Checked && SyntaxFacts.IsCheckedOperator(method.Name) ? 1152opFactory = isChecked || (node.MethodOpt is { Name: string name } && SyntaxFacts.IsCheckedOperator(name)) ?
Operations\CSharpOperationFactory.cs (5)
1130bool isChecked = boundConversion.Checked && (conversion.IsNumeric || (boundConversion.SymbolOpt is not null && SyntaxFacts.IsCheckedOperator(boundConversion.SymbolOpt.Name))); 1364bool isChecked = boundCompoundAssignmentOperator.Operator.Kind.IsChecked() || (method is not null && SyntaxFacts.IsCheckedOperator(method.Name)); 1390bool isChecked = boundIncrementOperator.OperatorKind.IsChecked() || (boundIncrementOperator.MethodOpt is not null && SyntaxFacts.IsCheckedOperator(boundIncrementOperator.MethodOpt.Name)); 1440bool isChecked = boundUnaryOperator.OperatorKind.IsChecked() || (boundUnaryOperator.MethodOpt is not null && SyntaxFacts.IsCheckedOperator(boundUnaryOperator.MethodOpt.Name)); 1526bool isChecked = boundBinaryOperator.OperatorKind.IsChecked() || (boundBinaryOperator.Method is not null && SyntaxFacts.IsCheckedOperator(boundBinaryOperator.Method.Name));
Parser\Blender.Cursor.cs (1)
182for (var node = cursor.CurrentNodeOrToken; node.Kind() != SyntaxKind.None && !SyntaxFacts.IsAnyToken(node.Kind()); node = cursor.CurrentNodeOrToken)
Parser\Blender.Reader.cs (1)
310return SyntaxFacts.IsContextualKeyword(kind);
Parser\DirectiveParser.cs (3)
662if (!SyntaxFacts.IsHexDigit(c)) 779left = SyntaxFactory.BinaryExpression(SyntaxFacts.GetBinaryExpression(op.Kind), left, op, right); 811return SyntaxFactory.LiteralExpression(SyntaxFacts.GetLiteralExpression(k), this.EatToken());
Parser\DocumentationCommentParser.cs (14)
534current.ValueText != SyntaxFacts.GetText(openQuote.Kind) && 678return token.Text.Length == 1 && SyntaxFacts.IsNonAsciiQuotationMark(token.Text[0]); 806return new XmlSyntaxDiagnosticInfo(offset, length, XmlParseErrorCode.XML_InvalidToken, SyntaxFacts.GetText(actual)); 827return new XmlSyntaxDiagnosticInfo(XmlParseErrorCode.XML_InvalidToken, SyntaxFacts.GetText(actual)); 989if (SyntaxFacts.IsAnyOverloadableOperator(CurrentToken.Kind)) 1002if (SyntaxFacts.IsUnaryOperatorDeclarationToken(CurrentToken.Kind) || SyntaxFacts.IsBinaryExpressionOperatorToken(CurrentToken.Kind)) 1103Debug.Assert(SyntaxFacts.IsAnyOverloadableOperator(operatorToken.Kind)); 1115(isConversion || SyntaxFacts.IsAnyOverloadableOperator(CurrentToken.Kind))) 1238return SyntaxFacts.IsPredefinedType(kind); 1312SyntaxFacts.IsPredefinedType(CurrentToken.Kind)) 1372if (SyntaxFacts.IsPredefinedType(CurrentToken.Kind)) 1530return CurrentToken.Text == SyntaxFacts.GetText(SyntaxKind.LessThanToken) || 1598return CurrentToken.Text == SyntaxFacts.GetText(SyntaxKind.LessThanToken) ||
Parser\LanguageParser.cs (53)
51return kind == SyntaxKind.IdentifierToken || SyntaxFacts.IsKeywordKind(kind); 1059if (SyntaxFacts.IsLiteralExpression(this.CurrentToken.Kind)) 1571if (SyntaxFacts.IsPredefinedType(this.CurrentToken.Kind)) 1608return !SyntaxFacts.IsContextualKeyword(nextToken.ContextualKind) && GetModifierExcludingScoped(nextToken) != DeclarationModifiers.None; 2160AddTrailingSkippedSyntax(bounds, this.AddError(separatorToken, ErrorCode.ERR_UnexpectedToken, SyntaxFacts.GetText(SyntaxKind.CommaToken))); 2232? this.AddError(this.EatToken(), ErrorCode.ERR_UnexpectedToken, SyntaxFacts.GetText(SyntaxKind.QuestionToken)) 3601possibleConversion = !SyntaxFacts.IsAnyOverloadableOperator(this.PeekToken(2).Kind); 3605possibleConversion = !SyntaxFacts.IsAnyOverloadableOperator(this.PeekToken(1).Kind); 3812if (SyntaxFacts.IsAnyOverloadableOperator(this.CurrentToken.Kind)) 3832SyntaxDiagnosticInfo diagInfo = MakeError(opTokenErrorOffset, opTokenErrorWidth, ErrorCode.ERR_BadOperatorSyntax, SyntaxFacts.GetText(SyntaxKind.PlusToken)); 3838type = this.AddError(type, ErrorCode.ERR_BadOperatorSyntax, SyntaxFacts.GetText(SyntaxKind.PlusToken)); 3879if (opToken.IsMissing || !SyntaxFacts.IsOverloadableUnaryOperator(opKind)) 3887if (opToken.IsMissing || !SyntaxFacts.IsOverloadableBinaryOperator(opKind)) 3900else if (SyntaxFacts.IsOverloadableBinaryOperator(opKind)) 3902opToken = this.AddError(opToken, ErrorCode.ERR_BadBinOpArgs, SyntaxFacts.GetText(opKind)); 3904else if (SyntaxFacts.IsOverloadableUnaryOperator(opKind)) 3906opToken = this.AddError(opToken, ErrorCode.ERR_BadUnOpArgs, SyntaxFacts.GetText(opKind)); 3921SyntaxFacts.IsOverloadableUnaryOperator(opKind) || 3922SyntaxFacts.IsOverloadableBinaryOperator(opKind))) 4162|| SyntaxFacts.GetAccessorDeclarationKind(this.CurrentToken.ContextualKind) != SyntaxKind.None 4371if (this.IsIncrementalAndFactoryContextMatches && SyntaxFacts.IsAccessorDeclaration(this.CurrentNodeKind)) 5224SyntaxFacts.IsBinaryExpressionOperatorToken(currentTokenKind); 5664if (!SyntaxFacts.IsContextualKeyword(((CSharp.Syntax.IdentifierNameSyntax)this.CurrentNode).Identifier.Kind())) 6241var contextualKind = SyntaxFacts.GetContextualKeywordKind(token.ValueText); 7159return SyntaxFacts.IsPredefinedType(keyword); 7413if (SyntaxFacts.IsLiteral(nextTokenKind)) 7418if (SyntaxFacts.IsPredefinedType(nextTokenKind)) 8128(SyntaxFacts.IsPredefinedType(tk) && 8286else if (SyntaxFacts.IsPredefinedType(tk)) 8514if (SyntaxFacts.GetBaseTypeDeclarationKind(nextToken.Kind) != SyntaxKind.None) 8522if (SyntaxFacts.IsPredefinedType(PeekToken(2).Kind)) 9052SyntaxFacts.GetCheckStatement(keyword.Kind), 9280skippedForToken = this.AddError(skippedForToken, ErrorCode.ERR_SyntaxError, SyntaxFacts.GetText(SyntaxKind.ForEachKeyword)); 9919SyntaxFacts.IsName(((NullableTypeSyntax)declaration.Type).ElementType.Kind) && 10600|| SyntaxFacts.IsAnyUnaryExpression(tk) 10601|| (allowBinaryExpressions && SyntaxFacts.IsBinaryExpression(tk)) 10602|| (allowAssignmentExpressions && SyntaxFacts.IsAssignmentExpressionOperatorToken(tk)); 10818return SyntaxFacts.IsPrefixUnaryExpression(kind) && kind is not SyntaxKind.RefKeyword and not SyntaxKind.OutKeyword; 10823return SyntaxFacts.IsBinaryExpression(kind); 10828return SyntaxFacts.IsAssignmentExpressionOperatorToken(kind); 10918return this.AddError(this.CreateMissingIdentifierName(), ErrorCode.ERR_InvalidExprTerm, SyntaxFacts.GetText(tk)); 10928var opKind = SyntaxFacts.GetPrefixUnaryExpression(tk); 10974: this.AddError(result, ErrorCode.ERR_InvalidExprTerm, SyntaxFacts.GetText(tk)); 11158return (token1Kind, SyntaxFacts.GetBinaryExpression(token1Kind)); 11161return (token1Kind, SyntaxFacts.GetAssignmentExpression(token1Kind)); 11487return _syntaxFactory.LiteralExpression(SyntaxFacts.GetLiteralExpression(tk), this.EatToken()); 11518return this.AddError(_syntaxFactory.RefExpression(refKeyword, this.ParseExpressionCore()), ErrorCode.ERR_InvalidExprTerm, SyntaxFacts.GetText(tk)); 11532expr = this.AddError(expr, ErrorCode.ERR_InvalidExprTerm, SyntaxFacts.GetText(tk)); 11547expr = this.AddError(expr, ErrorCode.ERR_InvalidExprTerm, SyntaxFacts.GetText(tk)); 11577expr = _syntaxFactory.PostfixUnaryExpression(SyntaxFacts.GetPostfixUnaryExpression(this.CurrentToken.Kind), expr, this.EatToken()); 12106&& !SyntaxFacts.IsPredefinedType(tk.Kind) 13553fc = this.AddError(fc, ErrorCode.WRN_PrecedenceInversion, SyntaxFacts.GetText(SyntaxKind.FromKeyword)); 13620(this.CurrentToken.Kind != SyntaxKind.IdentifierToken || SyntaxFacts.IsQueryContextualKeyword(this.CurrentToken.ContextualKind)))
Parser\LanguageParser_InterpolatedString.cs (6)
195var isBlankLine = (currentIndex == text.Length && isLast) || (currentIndex < text.Length && SyntaxFacts.IsNewLine(text[currentIndex])); 284if (openBracePosition > 0 && SyntaxFacts.IsNewLine(originalText[openBracePosition - 1])) 305SyntaxFacts.IsWhitespace(currentLineChar) && 306SyntaxFacts.IsWhitespace(indentationLineChar)) 326while (currentIndex < text.Length && SyntaxFacts.IsWhitespace(text[currentIndex])) 337if (!SyntaxFacts.IsNewLine(ch))
Parser\LanguageParser_Patterns.cs (4)
79if (SyntaxFacts.IsPredefinedType(tk)) 264return !SyntaxFacts.IsBinaryExpressionOperatorToken(kind) || 265GetPrecedence(SyntaxFacts.GetBinaryExpression(kind)) <= precedence; 417if (SyntaxFacts.IsBinaryExpression(tk)) return true; // `e is int and && true` is valid C# 7.0 code with `and` being a designator
Parser\Lexer.cs (68)
422Debug.Assert(SyntaxFacts.IsPunctuationOrKeyword(info.Kind)); 678if (SyntaxFacts.IsIdentifierStartCharacter(character)) 705if (SyntaxFacts.IsIdentifierStartCharacter(character)) 840else if (!(isHex ? SyntaxFacts.IsHexDigit(ch) : 841isBinary ? SyntaxFacts.IsBinaryDigit(ch) : 842SyntaxFacts.IsDecDigit(ch))) 1187var bit = (ulong)SyntaxFacts.BinaryValue(c); 1549if (_identLen == 0 && ch > 127 && SyntaxFacts.IsIdentifierStartCharacter(ch)) 1553else if (_identLen > 0 && ch > 127 && SyntaxFacts.IsIdentifierPartCharacter(ch)) 1623if ((valueText.Length == 0) || !valueText.All(SyntaxFacts.IsHexDigit)) 1772if (_identLen == 0 && consumedChar > 127 && SyntaxFacts.IsIdentifierStartCharacter(consumedChar)) 1776else if (_identLen > 0 && consumedChar > 127 && SyntaxFacts.IsIdentifierPartCharacter(consumedChar)) 1848SyntaxKind keywordKind = SyntaxFacts.GetPreprocessorKeywordKind(info.Text); 1849if (SyntaxFacts.IsPreprocessorContextualKeyword(keywordKind)) 1866else if (SyntaxFacts.IsContextualKeyword(info.Kind)) 1907if (SyntaxFacts.IsWhitespace(ch)) 1911else if (SyntaxFacts.IsNewLine(ch)) 2061if (position == 0 || SyntaxFacts.IsNewLine(text[position - 1])) 2160while (SyntaxFacts.IsNewLine(this.TextWindow.PeekChar())) 2176if (ch == SlidingTextWindow.InvalidCharacter || SyntaxFacts.IsNewLine(ch)) 2232while (!SyntaxFacts.IsNewLine(ch = TextWindow.PeekChar()) && 2255if (SyntaxFacts.IsNewLine(ch)) 2296if (ch > 127 && SyntaxFacts.IsWhitespace(ch)) 2385if (SyntaxFacts.IsWhitespace(TextWindow.PeekChar())) 2445if (SyntaxFacts.IsNewLine(ch)) 2450allWhitespace = allWhitespace && SyntaxFacts.IsWhitespace(ch); 2484if (SyntaxFacts.IsNewLine(ch)) 2640if (SyntaxFacts.IsIdentifierStartCharacter(character)) 2650if (!isEscaped && SyntaxFacts.IsNewLine(character)) 2655if (SyntaxFacts.IsIdentifierStartCharacter(character)) 2746if (SyntaxFacts.IsWhitespace(ch)) 2751if (SyntaxFacts.IsNewLine(ch)) 2846if (SyntaxFacts.IsNewLine(ch)) 2972while (SyntaxFacts.IsHexDigit(ch = TextWindow.PeekChar())) 2979charValue = (charValue << 4) + (uint)SyntaxFacts.HexValue(ch); 2985while (SyntaxFacts.IsDecDigit(ch = TextWindow.PeekChar())) 2992charValue = (charValue << 3) + (charValue << 1) + (uint)SyntaxFacts.DecValue(ch); 3025if (SyntaxFacts.IsWhitespace(ch) || SyntaxFacts.IsNewLine(ch)) 3135if (SyntaxFacts.IsNewLine(ch)) 3259else if (SyntaxFacts.IsWhitespace(ch) || SyntaxFacts.IsNewLine(ch)) 3408if (SyntaxFacts.IsNewLine(ch)) 3474if (SyntaxFacts.IsNewLine(ch)) 3646if (SyntaxFacts.IsNewLine(consumedChar)) 3768string valueText = SyntaxFacts.GetText(info.Kind); 3793if (SyntaxFacts.IsContextualKeyword(keywordKind)) 4011if (SyntaxFacts.IsNewLine(ch)) 4065if (SyntaxFacts.IsNewLine(ch)) 4141if (SyntaxFacts.IsNewLine(ch)) 4195if (SyntaxFacts.IsNewLine(ch)) 4264if (SyntaxFacts.IsNewLine(ch)) 4319if (SyntaxFacts.IsNewLine(ch)) 4423if (SyntaxFacts.IsWhitespace(ch)) 4472&& (SyntaxFacts.IsWhitespace(ch) || SyntaxFacts.IsNewLine(ch))) 4520if (SyntaxFacts.IsWhitespace(ch)) 4525if (SyntaxFacts.IsNewLine(ch)) 4614if (!SyntaxFacts.IsHexDigit(TextWindow.PeekChar())) 4626if (!SyntaxFacts.IsHexDigit(character)) 4636uintChar = (uint)((uintChar << 4) + SyntaxFacts.HexValue(character)); 4659if (!SyntaxFacts.IsHexDigit(TextWindow.PeekChar())) 4671if (!SyntaxFacts.IsHexDigit(ch2)) 4684intChar = (intChar << 4) + SyntaxFacts.HexValue(ch2); 4760while (SyntaxFacts.IsHexDigit(digit = TextWindow.PeekChar())) 4767uintChar = (uintChar << 4) + (uint)SyntaxFacts.HexValue(digit); 4778while (SyntaxFacts.IsDecDigit(digit = TextWindow.PeekChar())) 4785uintChar = (uintChar << 3) + (uintChar << 1) + (uint)SyntaxFacts.DecValue(digit);
Parser\Lexer_RawStringLiteral.cs (11)
46if (!SyntaxFacts.IsWhitespace(ch)) 68if (SyntaxFacts.IsNewLine(TextWindow.PeekChar())) 135if (SyntaxFacts.IsNewLine(currentChar)) 197Debug.Assert(SyntaxFacts.IsNewLine(TextWindow.PeekChar())); 224Debug.Assert(SyntaxFacts.IsNewLine(TextWindow.PeekChar())); 289if (SyntaxFacts.IsNewLine(currentChar)) 317Debug.Assert(SyntaxFacts.IsNewLine(TextWindow.PeekChar())); 341var isBlankLine = SyntaxFacts.IsNewLine(TextWindow.PeekChar()); 382if (SyntaxFacts.IsNewLine(currentChar)) 402SyntaxFacts.IsWhitespace(currentLineChar) && 403SyntaxFacts.IsWhitespace(indentationLineChar))
Parser\Lexer_StringLiteral.cs (4)
57else if (SyntaxFacts.IsNewLine(ch) || 363(!allowNewline && SyntaxFacts.IsNewLine(ch)) || 488if (SyntaxFacts.IsNewLine(window.PeekChar())) 729if (SyntaxFacts.IsNewLine(_lexer.TextWindow.PeekChar()))
Parser\LexerCache.cs (2)
24var kind = SyntaxFacts.GetKeywordKind(key); 27kind = SyntaxFacts.GetContextualKeywordKind(key);
Parser\SlidingTextWindow.cs (2)
303Debug.Assert(SyntaxFacts.IsNewLine(this.PeekChar())); 309Debug.Assert(SyntaxFacts.IsNewLine(currentChar));
Parser\SyntaxParser.cs (10)
523Debug.Assert(SyntaxFacts.IsAnyToken(kind)); 539Debug.Assert(SyntaxFacts.IsAnyToken(expected)); 583Debug.Assert(SyntaxFacts.IsAnyToken(kind)); 597Debug.Assert(SyntaxFacts.IsAnyToken(kind)); 611Debug.Assert(SyntaxFacts.IsAnyToken(kind)); 630Debug.Assert(SyntaxFacts.IsAnyToken(kind)); 644Debug.Assert(SyntaxFacts.IsAnyToken(kind)); 662return new SyntaxDiagnosticInfo(offset, width, code, SyntaxFacts.GetText(expected)); 666return new SyntaxDiagnosticInfo(offset, width, code, /*unused*/string.Empty, SyntaxFacts.GetText(actual)); 687if (SyntaxFacts.IsReservedKeyword(actual))
SourceGeneration\CSharpSyntaxHelper.cs (1)
23=> SyntaxFacts.IsValidIdentifier(name);
SymbolDisplay\ObjectDisplay.cs (1)
302if (SyntaxFacts.IsNewLine(c))
SymbolDisplay\SymbolDisplayVisitor.cs (4)
141SyntaxKind kind = SyntaxFacts.GetKeywordKind(identifier); 224SyntaxFacts.GetText(SyntaxKind.GlobalKeyword))); 351Builder.Add(CreatePart(SymbolDisplayPartKind.Punctuation, null, SyntaxFacts.GetText(punctuationKind))); 356Builder.Add(CreatePart(SymbolDisplayPartKind.Keyword, null, SyntaxFacts.GetText(keywordKind)));
SymbolDisplay\SymbolDisplayVisitor.Members.cs (3)
675return SyntaxFacts.GetOperatorKind(operatorName); 696if (SyntaxFacts.IsCheckedOperator(operatorName)) 703SyntaxFacts.GetText(operatorKind)));
SymbolDisplay\SymbolDisplayVisitor_Minimal.cs (1)
55return SyntaxFacts.IsInNamespaceOrTypeContext(startNode as ExpressionSyntax) || token.IsKind(SyntaxKind.NewKeyword) || this.InNamespaceOrType;
Symbols\Metadata\PE\PEMethodSymbol.cs (1)
1282if (!SyntaxFacts.IsValidIdentifier(this.Name) && !this.ExplicitInterfaceImplementations.IsEmpty)
Symbols\PublicModel\PreprocessingSymbol.cs (2)
130bool ISymbol.CanBeReferencedByName => SyntaxFacts.IsValidIdentifier(_name) && !SyntaxFacts.ContainsDroppedIdentifierCharacters(_name);
Symbols\Source\AttributeLocation.cs (3)
111var kind = SyntaxFacts.GetKeywordKind(token.ValueText); 114kind = SyntaxFacts.GetContextualKeywordKind(token.ValueText); 117Debug.Assert(result == AttributeLocation.None ^ SyntaxFacts.IsAttributeTargetSpecifier(kind));
Symbols\Source\LocalFunctionSymbol.cs (1)
41: base(syntax.GetReference(), isIterator: SyntaxFacts.HasYieldOperations(syntax.Body))
Symbols\Source\ModifierUtils.cs (27)
280return SyntaxFacts.GetText(SyntaxKind.AbstractKeyword); 282return SyntaxFacts.GetText(SyntaxKind.SealedKeyword); 284return SyntaxFacts.GetText(SyntaxKind.StaticKeyword); 286return SyntaxFacts.GetText(SyntaxKind.NewKeyword); 288return SyntaxFacts.GetText(SyntaxKind.PublicKeyword); 290return SyntaxFacts.GetText(SyntaxKind.ProtectedKeyword); 292return SyntaxFacts.GetText(SyntaxKind.InternalKeyword); 294return SyntaxFacts.GetText(SyntaxKind.ProtectedKeyword) + " " + SyntaxFacts.GetText(SyntaxKind.InternalKeyword); 296return SyntaxFacts.GetText(SyntaxKind.PrivateKeyword); 298return SyntaxFacts.GetText(SyntaxKind.PrivateKeyword) + " " + SyntaxFacts.GetText(SyntaxKind.ProtectedKeyword); 300return SyntaxFacts.GetText(SyntaxKind.ReadOnlyKeyword); 302return SyntaxFacts.GetText(SyntaxKind.ConstKeyword); 304return SyntaxFacts.GetText(SyntaxKind.VolatileKeyword); 306return SyntaxFacts.GetText(SyntaxKind.ExternKeyword); 308return SyntaxFacts.GetText(SyntaxKind.PartialKeyword); 310return SyntaxFacts.GetText(SyntaxKind.UnsafeKeyword); 312return SyntaxFacts.GetText(SyntaxKind.FixedKeyword); 314return SyntaxFacts.GetText(SyntaxKind.VirtualKeyword); 316return SyntaxFacts.GetText(SyntaxKind.OverrideKeyword); 318return SyntaxFacts.GetText(SyntaxKind.AsyncKeyword); 320return SyntaxFacts.GetText(SyntaxKind.RefKeyword); 322return SyntaxFacts.GetText(SyntaxKind.RequiredKeyword); 324return SyntaxFacts.GetText(SyntaxKind.ScopedKeyword); 326return SyntaxFacts.GetText(SyntaxKind.FileKeyword); 454SyntaxFacts.GetText(modifierToken.Kind()));
Symbols\Source\ParameterHelpers.cs (5)
620diagnostics.Add(ErrorCode.ERR_BadFuncPointerParamModifier, modifier.GetLocation(), SyntaxFacts.GetText(modifier.Kind())); 632diagnostics.Add(ErrorCode.ERR_DupParamMod, modifier.GetLocation(), SyntaxFacts.GetText(modifier.Kind())); 637diagnostics.Add(ErrorCode.ERR_BadParameterModifiers, modifier.GetLocation(), SyntaxFacts.GetText(modifier.Kind()), SyntaxFacts.GetText(otherModifierKind)); 642diagnostics.Add(ErrorCode.ERR_ParamsCantBeWithModifier, modifier.GetLocation(), SyntaxFacts.GetText(otherModifierKind));
Symbols\Source\SourceConstructorSymbol.cs (1)
32base(containingType, location, syntax, SyntaxFacts.HasYieldOperations(syntax),
Symbols\Source\SourceCustomEventAccessorSymbol.cs (1)
33isIterator: SyntaxFacts.HasYieldOperations(syntax.Body),
Symbols\Source\SourceDestructorSymbol.cs (1)
23base(containingType, syntax.GetReference(), GetSymbolLocation(syntax, out Location location), isIterator: SyntaxFacts.HasYieldOperations(syntax.Body),
Symbols\Source\SourceEventSymbol.cs (2)
560diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, SyntaxFacts.GetText(SyntaxKind.AbstractKeyword)); 565diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, SyntaxFacts.GetText(SyntaxKind.VirtualKeyword));
Symbols\Source\SourceMemberContainerSymbol.cs (6)
512if (name == SyntaxFacts.GetText(contextualKind) && compilation.LanguageVersion >= featureId.RequiredVersion()) 2268diagnostics.Add(ErrorCode.ERR_MemberAlreadyExists, indexer.GetFirstLocation(), SyntaxFacts.GetText(SyntaxKind.ThisKeyword), this); 2515SyntaxFacts.GetText(SyntaxFacts.GetOperatorKind(operatorName2))); 5234else if (reportMisplacedGlobalCode && !SyntaxFacts.IsSimpleProgramTopLevelStatement((GlobalStatementSyntax)m)) 5243SyntaxFacts.IsTypeDeclaration(m.Kind()) ||
Symbols\Source\SourceMemberContainerSymbol_ImplementationChecks.cs (1)
905var accessibility = SyntaxFacts.GetText(overriddenMember.DeclaredAccessibility);
Symbols\Source\SourceMemberFieldSymbol.cs (2)
236diagnostics.Add(ErrorCode.ERR_BadMemberFlag, errorLocation, SyntaxFacts.GetText(SyntaxKind.RequiredKeyword)); 456diagnostics.Add(ErrorCode.ERR_BadMemberFlag, ErrorLocation, SyntaxFacts.GetText(SyntaxKind.ScopedKeyword));
Symbols\Source\SourceMethodSymbolWithAttributes.cs (1)
752if (name == null || !SyntaxFacts.IsValidIdentifier(name))
Symbols\Source\SourceNamedTypeSymbol.cs (1)
1395if (name == null || !SyntaxFacts.IsValidIdentifier(name))
Symbols\Source\SourceNamedTypeSymbol_Bases.cs (1)
460if (typeSyntax.Kind() != SyntaxKind.PredefinedType && !SyntaxFacts.IsName(typeSyntax.Kind()))
Symbols\Source\SourceOrdinaryMethodSymbol.cs (4)
59isIterator: SyntaxFacts.HasYieldOperations(syntax.Body), 840diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, SyntaxFacts.GetText(SyntaxKind.SealedKeyword)); 862diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, SyntaxFacts.GetText(SyntaxKind.AbstractKeyword)); 867diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, SyntaxFacts.GetText(SyntaxKind.VirtualKeyword));
Symbols\Source\SourcePropertyAccessorSymbol.cs (1)
56isIterator: SyntaxFacts.HasYieldOperations(syntax.Body),
Symbols\Source\SourcePropertySymbol.cs (1)
483diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, SyntaxFacts.GetText(SyntaxKind.RequiredKeyword));
Symbols\Source\SourcePropertySymbolBase.cs (6)
346{ MethodKind: MethodKind.PropertyGet, IsInitOnly: false } => SyntaxFacts.GetText(SyntaxKind.GetKeyword), 347{ MethodKind: MethodKind.PropertySet, IsInitOnly: false } => SyntaxFacts.GetText(SyntaxKind.SetKeyword), 348{ MethodKind: MethodKind.PropertySet, IsInitOnly: true } => SyntaxFacts.GetText(SyntaxKind.InitKeyword), 1097diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, SyntaxFacts.GetText(SyntaxKind.AbstractKeyword)); 1102diagnostics.Add(ErrorCode.ERR_BadMemberFlag, location, SyntaxFacts.GetText(SyntaxKind.VirtualKeyword)); 1697if (indexerName == null || !SyntaxFacts.IsValidIdentifier(indexerName))
Symbols\Source\SourceUserDefinedConversionSymbol.cs (1)
72isIterator: SyntaxFacts.HasYieldOperations(syntax.Body),
Symbols\Source\SourceUserDefinedOperatorSymbol.cs (4)
28if (SyntaxFacts.IsCheckedOperator(name)) 34diagnostics.Add(ErrorCode.ERR_OperatorCantBeChecked, syntax.CheckedKeyword.GetLocation(), SyntaxFacts.GetText(SyntaxFacts.GetOperatorKind(name))); 77isIterator: SyntaxFacts.HasYieldOperations(syntax.Body),
Symbols\Symbol.cs (2)
709return SyntaxFacts.IsValidIdentifier(this.Name) && 710!SyntaxFacts.ContainsDroppedIdentifierCharacters(this.Name);
Symbols\Symbol_Attributes.cs (1)
227if (!SyntaxFacts.IsValidIdentifier((string?)arguments.Attribute.CommonConstructorArguments[0].ValueInternal))
Symbols\Synthesized\SynthesizedIntrinsicOperatorSymbol.cs (1)
56public override bool IsCheckedBuiltin => SyntaxFacts.IsCheckedOperator(this.Name);
Syntax\CSharpSyntaxNode.cs (1)
385if (!SyntaxFacts.IsDocumentationCommentTrivia(trivia.Kind()))
Syntax\InternalSyntax\CSharpSyntaxNode.cs (1)
77public override bool IsDocumentationCommentTrivia => SyntaxFacts.IsDocumentationCommentTrivia(this.Kind);
Syntax\InternalSyntax\SyntaxFactory.cs (2)
136Debug.Assert(SyntaxFacts.IsAnyToken(kind)); 141string defaultText = SyntaxFacts.GetText(kind);
Syntax\InternalSyntax\SyntaxToken.cs (3)
74if (!SyntaxFacts.IsAnyToken(kind)) 89if (!SyntaxFacts.IsAnyToken(kind)) 269get { return SyntaxFacts.GetText(this.Kind); }
Syntax\SyntaxExtensions.cs (1)
199return SyntaxFacts.IsInTypeOnlyContext(typeNode) && IsInContextWhichNeedsDynamicAttribute(typeNode);
Syntax\SyntaxFactory.cs (1)
262if (!SyntaxFacts.IsAnyToken(kind))
Syntax\SyntaxFacts.cs (8)
365return SyntaxFacts.GetText(PrivateKeyword); 367return SyntaxFacts.GetText(PrivateKeyword) + " " + SyntaxFacts.GetText(ProtectedKeyword); 369return SyntaxFacts.GetText(InternalKeyword); 371return SyntaxFacts.GetText(ProtectedKeyword); 373return SyntaxFacts.GetText(ProtectedKeyword) + " " + SyntaxFacts.GetText(InternalKeyword); 375return SyntaxFacts.GetText(PublicKeyword);
Syntax\SyntaxNormalizer.cs (13)
651if (!SyntaxFacts.IsPunctuation(next.Kind())) 836if (SyntaxFacts.IsLiteral(token.Kind()) && SyntaxFacts.IsLiteral(next.Kind())) 1006return SyntaxFacts.GetBinaryExpression(kind) != SyntaxKind.None; 1012return SyntaxFacts.GetAssignmentExpression(kind) != SyntaxKind.None; 1171return !SyntaxFacts.IsPreprocessorDirective(trivia.Kind()); 1189return SyntaxFacts.IsPreprocessorDirective(kind); 1203return SyntaxFacts.IsPreprocessorDirective(kind); 1237return text.Length > 0 && SyntaxFacts.IsNewLine(text.Last()); 1264return SyntaxFacts.IsLiteral(kind) 1272return SyntaxFacts.IsKeywordKind(kind) || SyntaxFacts.IsPreprocessorKeyword(kind); 1299if (SyntaxFacts.IsPreprocessorDirective(trivia.Kind()))
Microsoft.CodeAnalysis.CSharp.CodeStyle (45)
src\Analyzers\CSharp\Analyzers\AddBraces\CSharpAddBracesDiagnosticAnalyzer.cs (1)
117SyntaxFacts.GetText(firstToken.Kind())));
src\Analyzers\CSharp\Analyzers\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementDiagnosticAnalyzer.cs (1)
137if (!SyntaxFacts.IsWhitespace(text[i]))
src\Analyzers\CSharp\Analyzers\OrderModifiers\CSharpOrderModifiersHelper.cs (2)
21var kind = SyntaxFacts.GetKeywordKind(trimmed); 22return (int)(kind == SyntaxKind.None ? SyntaxFacts.GetContextualKeywordKind(trimmed) : kind);
src\Analyzers\CSharp\Analyzers\UseCollectionInitializer\CSharpUseCollectionInitializerAnalyzer.cs (1)
182var matchIndex = spreadElements.FindIndex(SyntaxFacts.AreEquivalent, current);
src\Analyzers\CSharp\Analyzers\UseCompoundAssignment\Utilities.cs (1)
31if (SyntaxFacts.GetAssignmentExpression(current) == assignmentExpressionKind)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CodeStyle\CSharpCodeStyleOptions.cs (1)
172defaultValue: new CodeStyleOption2<string>(string.Join(",", s_preferredModifierOrderDefault.Select(SyntaxFacts.GetText)), NotificationOption2.Silent));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CodeStyle\TypeStyle\TypeStyleHelper.cs (1)
225? SyntaxFacts.IsPredefinedType(predefinedType.Keyword.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ExpressionSyntaxExtensions.cs (1)
428name.Identifier.Text == SyntaxFacts.GetText(SyntaxKind.NameOfKeyword))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (1)
444if (SyntaxFacts.GetContextualKeywordKind(parameter.Name) is not SyntaxKind.UnderscoreToken)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SymbolDisplayPartExtensions.cs (1)
21if (SyntaxFacts.GetKeywordKind(text) != SyntaxKind.None)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (1)
603var hasLeadingDirective = node.GetLeadingTrivia().Any(t => SyntaxFacts.IsPreprocessorDirective(t.Kind()));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTokenExtensions.cs (3)
43=> token.ToString() == SyntaxFacts.GetText(kind); 70SyntaxFacts.GetContextualKeywordKind(simpleNameText) != SyntaxKind.None; 330if (SyntaxFacts.IsKeywordKind(token.Kind()))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTreeExtensions.cs (1)
30var result = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\CSharpTriviaFormatter.cs (3)
44=> SyntaxFacts.IsWhitespace(ch); 47=> SyntaxFacts.IsNewLine(ch); 87if (SyntaxFacts.IsPreprocessorDirective(trivia2.Kind()))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaDataFactory.Analyzer.cs (1)
128Contract.ThrowIfFalse(SyntaxFacts.IsPreprocessorDirective(trivia.Kind()));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaDataFactory.CodeShapeAnalyzer.cs (3)
67SyntaxFacts.IsPreprocessorDirective(trivia.Kind())) 248if (!SyntaxFacts.IsPreprocessorDirective(trivia.Kind())) 314if (!string.IsNullOrEmpty(triviaString) && SyntaxFacts.IsNewLine(triviaString.Last()))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaDataFactory.cs (2)
27=> SyntaxFacts.IsWhitespace(c) || SyntaxFacts.IsNewLine(c);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (1)
487=> triviaList.Sum(t => t.ToFullString().Replace("\r\n", "\r").Cast<char>().Count(c => SyntaxFacts.IsNewLine(c)));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\StructuredTriviaFormattingRule.cs (1)
29if (previousToken.Kind() == SyntaxKind.HashToken && SyntaxFacts.IsPreprocessorKeyword(currentToken.Kind()))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (15)
89var needsEscaping = SyntaxFacts.GetKeywordKind(identifier) != SyntaxKind.None; 101(SyntaxFacts.IsAnyUnaryExpression(kind) && 103(SyntaxFacts.IsBinaryExpression(kind) && (token.Parent is BinaryExpressionSyntax or OperatorDeclarationSyntax or RelationalPatternSyntax)) || 104(SyntaxFacts.IsAssignmentExpressionOperatorToken(kind) && token.Parent is AssignmentExpressionSyntax); 108=> SyntaxFacts.IsReservedKeyword(token.Kind()); 111=> SyntaxFacts.IsContextualKeyword(token.Kind()); 114=> SyntaxFacts.IsPreprocessorKeyword(token.Kind()); 447=> SyntaxFacts.GetText((SyntaxKind)kind); 450=> SyntaxFacts.IsIdentifierStartCharacter(c); 453=> SyntaxFacts.IsIdentifierPartCharacter(c); 584=> SyntaxFacts.IsInNamespaceOrTypeContext(node as ExpressionSyntax); 1229=> SyntaxFacts.IsDocumentationCommentTrivia(node.Kind()); 1250if (SyntaxFacts.IsNamespaceMemberDeclaration(node.Kind())) 1295=> SyntaxFacts.IsTypeDeclaration(node.Kind()); 1370=> SyntaxFacts.IsPreprocessorDirective(trivia.Kind());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (2)
119var isInNamespaceOrTypeContext = SyntaxFacts.IsInNamespaceOrTypeContext(originalNode as ExpressionSyntax); 646=> SyntaxFacts.IsInNamespaceOrTypeContext(node);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpTypeStyleHelper.State.cs (1)
89/// to var. <see cref="SyntaxFacts.IsPredefinedType(SyntaxKind)"/> considers string
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (33)
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs (1)
85Debug.Assert(SyntaxFacts.IsAssignmentExpression(nodeToGenerate));
src\Analyzers\CSharp\CodeFixes\DocumentationComments\CSharpRemoveDocCommentNodeCodeFixProvider.cs (1)
56if (!SyntaxFacts.IsWhitespace(c))
src\Analyzers\CSharp\CodeFixes\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementCodeFixProvider.cs (1)
87if (end < text.Length && SyntaxFacts.IsNewLine(text[end]))
src\Analyzers\CSharp\CodeFixes\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementCodeFixProvider.cs (1)
89if (end < text.Length && SyntaxFacts.IsNewLine(text[end]))
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (1)
291return SyntaxFacts.IsInTypeOnlyContext(originalName)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\ConversionGenerator.cs (1)
63var checkedToken = SyntaxFacts.IsCheckedOperator(method.MetadataName)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (1)
749modifier => SyntaxFacts.IsAccessibilityModifier(modifier.Kind()));
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpDeclarationComparer.cs (2)
15private static readonly Dictionary<SyntaxKind, int> s_kindPrecedenceMap = new(SyntaxFacts.EqualityComparer) 36private static readonly Dictionary<SyntaxKind, int> s_operatorPrecedenceMap = new(SyntaxFacts.EqualityComparer)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpFlagsEnumGenerator.cs (1)
39=> SyntaxFacts.IsValidIdentifier(name);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\OperatorGenerator.cs (2)
81var operatorSyntaxKind = SyntaxFacts.GetOperatorKind(method.MetadataName); 88var checkedToken = SyntaxFacts.IsCheckedOperator(method.MetadataName)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (1)
699SyntaxFacts.IsInTypeOnlyContext(typedParent) &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (2)
20private static readonly ISet<SyntaxKind> s_validLocalFunctionModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 2879if (token.Text == SyntaxFacts.GetText(SyntaxKind.AsyncKeyword))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\StringExtensions.cs (3)
23var needsEscaping = SyntaxFacts.GetKeywordKind(identifier) != SyntaxKind.None; 26needsEscaping = needsEscaping || (isQueryContext && SyntaxFacts.IsQueryContextualKeyword(SyntaxFacts.GetContextualKeywordKind(identifier)));
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\SyntaxTreeExtensions.cs (1)
149if (SyntaxFacts.IsKeywordKind(token.Kind()))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Utilities\CSharpSimplificationHelpers.cs (3)
23if (SyntaxFacts.GetKeywordKind(syntaxToken.ValueText) == SyntaxKind.None && SyntaxFacts.GetContextualKeywordKind(syntaxToken.ValueText) == SyntaxKind.None) 28if (SyntaxFacts.GetContextualKeywordKind(syntaxToken.ValueText) == SyntaxKind.UnderscoreToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Utilities\SyntaxKindSet.cs (11)
11public static readonly ISet<SyntaxKind> AllTypeModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 27public static readonly ISet<SyntaxKind> AllMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 47public static readonly ISet<SyntaxKind> AllGlobalMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 61public static readonly ISet<SyntaxKind> AccessibilityModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 69public static readonly ISet<SyntaxKind> AllTypeDeclarations = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 79public static readonly ISet<SyntaxKind> ClassInterfaceStructRecordTypeDeclarations = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 88public static readonly ISet<SyntaxKind> ClassInterfaceRecordTypeDeclarations = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 95public static readonly ISet<SyntaxKind> ClassRecordTypeDeclarations = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 101public static readonly ISet<SyntaxKind> ClassStructRecordTypeDeclarations = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 109public static readonly ISet<SyntaxKind> StructOnlyTypeDeclarations = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 115public static readonly ISet<SyntaxKind> InterfaceOnlyTypeDeclarations = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Microsoft.CodeAnalysis.CSharp.EditorFeatures (18)
AutomaticCompletion\AutomaticLineEnderCommandHandler.cs (3)
49private static readonly string s_semicolon = SyntaxFacts.GetText(SyntaxKind.SemicolonToken); 638=> string.Concat(SyntaxFacts.GetText(SyntaxKind.OpenBraceToken), 640SyntaxFacts.GetText(SyntaxKind.CloseBraceToken));
BlockCommentEditing\BlockCommentEditingCommandHandler.cs (3)
90while (end < snapshot.Length && SyntaxFacts.IsWhitespace(end.GetChar()) && !SyntaxFacts.IsNewLine(end.GetChar())) 253while (currentChar < caretPosition && SyntaxFacts.IsWhitespace(textSnapshot[currentChar]))
Interactive\CSharpSendToInteractiveSubmissionProvider.cs (2)
113return SyntaxFacts.IsTypeDeclaration(kind) 114|| SyntaxFacts.IsGlobalMemberDeclaration(kind)
StringCopyPaste\StringCopyPasteHelpers.cs (5)
92if (!SyntaxFacts.IsWhitespace(ch)) 108if (!SyntaxFacts.IsWhitespace(text[i])) 138/// Removes all characters matching <see cref="SyntaxFacts.IsWhitespace(char)"/> from the start of <paramref 144while (start < value.Length && SyntaxFacts.IsWhitespace(value[start])) 562if (SyntaxFacts.IsNewLine(text[i]))
StringCopyPaste\StringInfo.cs (4)
113while (SyntaxFacts.IsWhitespace(SafeCharAt(text, rawStart))) 123Contract.ThrowIfFalse(SyntaxFacts.IsNewLine(text[rawStart])); 129while (SyntaxFacts.IsWhitespace(SafeCharAt(text, rawEnd - 1))) 138Contract.ThrowIfFalse(SyntaxFacts.IsNewLine(text[rawEnd - 1]));
StringCopyPaste\UnknownSourcePasteProcessor.cs (1)
290else if (!lastChange && lineWithoutLeadingWhitespace.Length > 0 && SyntaxFacts.IsNewLine(lineWithoutLeadingWhitespace[0]))
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (2)
Completion\CompletionProviders\XmlDocumentationCommentCompletionProviderTests.cs (2)
887foreach (var keywordKind in SyntaxFacts.GetKeywordKinds()) 889var keywordText = SyntaxFacts.GetText(keywordKind);
Microsoft.CodeAnalysis.CSharp.EditorFeatures2.UnitTests (2)
Recommendations\KeywordRecommenderTests.cs (2)
17private static readonly Dictionary<SyntaxKind, AbstractSyntacticSingleKeywordRecommender> s_recommenderMap = new(SyntaxFacts.EqualityComparer); 48KeywordText = SyntaxFacts.GetText(kind);
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (6)
Semantics\OutVarTests.cs (2)
1038Assert.True(SyntaxFacts.IsInNamespaceOrTypeContext(typeSyntax)); 1039Assert.True(SyntaxFacts.IsInTypeOnlyContext(typeSyntax));
Semantics\PatternMatchingTestBase.cs (4)
104Assert.True(SyntaxFacts.IsInNamespaceOrTypeContext(typeSyntax)); 105Assert.True(SyntaxFacts.IsInTypeOnlyContext(typeSyntax)); 271Assert.True(SyntaxFacts.IsInNamespaceOrTypeContext(typeSyntax)); 272Assert.True(SyntaxFacts.IsInTypeOnlyContext(typeSyntax));
Microsoft.CodeAnalysis.CSharp.Features (135)
AddImport\CSharpAddImportFeatureService.cs (1)
404if (SyntaxFacts.GetKeywordKind(part) != SyntaxKind.None)
BraceMatching\AbstractCSharpBraceMatcher.cs (2)
12: base(new BraceCharacterAndKind(SyntaxFacts.GetText(openBrace)[0], (int)openBrace), 13new BraceCharacterAndKind(SyntaxFacts.GetText(closeBrace)[0], (int)closeBrace))
CodeLens\CSharpCodeLensDisplayInfoService.cs (1)
184while (scopeNode != null && !SyntaxFacts.IsNamespaceMemberDeclaration(scopeNode.Kind()))
CodeRefactorings\InlineTemporary\InlineTemporaryCodeRefactoringProvider.ReferenceRewriter.cs (1)
95!SyntaxFacts.IsReservedTupleElementName(id.Identifier.ValueText))
Completion\CompletionProviders\CompletionUtilities.cs (3)
24=> SyntaxFacts.IsIdentifierStartCharacter(ch); 27=> SyntaxFacts.IsIdentifierStartCharacter(ch) || SyntaxFacts.IsIdentifierPartCharacter(ch);
Completion\CompletionProviders\ExplicitInterfaceMemberCompletionProvider.CompletionSymbolDisplay.cs (3)
63builder.Append(SyntaxFacts.GetText(SyntaxFacts.GetOperatorKind(symbol.MetadataName))); 80if (SyntaxFacts.IsCheckedOperator(symbol.MetadataName))
Completion\CompletionProviders\ExplicitInterfaceMemberCompletionProvider.cs (1)
115if (!SyntaxFacts.IsIdentifierPartCharacter(memberString[i]))
Completion\CompletionProviders\ExplicitInterfaceTypeCompletionProvider.cs (1)
74if (SyntaxFacts.GetContextualKeywordKind(targetToken.ValueText) == SyntaxKind.AsyncKeyword)
Completion\CompletionProviders\OperatorsAndIndexer\UnnamedSymbolCompletionProvider_Operators.cs (2)
121=> SyntaxFacts.GetText(SyntaxFacts.GetOperatorKind(opName));
Completion\CompletionProviders\XmlDocCommentCompletionProvider.cs (2)
45foreach (var keywordKind in SyntaxFacts.GetKeywordKinds()) 47var keywordText = SyntaxFacts.GetText(keywordKind);
Completion\KeywordRecommenders\AbstractKeywordRecommender.cs (3)
14private static readonly ISet<SyntaxKind> s_validNonInterfaceMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 25private static readonly ISet<SyntaxKind> s_validInterfaceMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 37private static readonly ISet<SyntaxKind> s_validTypeModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\AbstractSyntacticSingleKeywordRecommender.cs (2)
36_keywordPriorityRecommendedKeywords = [new RecommendedKeyword(SyntaxFacts.GetText(keywordKind), 39_defaultPriorityRecommendedKeywords = [new RecommendedKeyword(SyntaxFacts.GetText(keywordKind),
Completion\KeywordRecommenders\AsyncKeywordRecommender.cs (1)
20private static readonly ISet<SyntaxKind> s_validLocalFunctionModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\ClassKeywordRecommender.cs (1)
14private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\ConstKeywordRecommender.cs (2)
14private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 23private static readonly ISet<SyntaxKind> s_validGlobalModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\DelegateKeywordRecommender.cs (1)
15private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\EnumKeywordRecommender.cs (1)
14private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\EventKeywordRecommender.cs (2)
15private static readonly ISet<SyntaxKind> s_validClassModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 31private static readonly ISet<SyntaxKind> s_validStructModifiers = new HashSet<SyntaxKind>(s_validClassModifiers, SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\ExplicitKeywordRecommender.cs (2)
14private static readonly ISet<SyntaxKind> s_validNonInterfaceMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 22private static readonly ISet<SyntaxKind> s_validInterfaceMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\ExternKeywordRecommender.cs (3)
15private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 29private static readonly ISet<SyntaxKind> s_validGlobalModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 39private static readonly ISet<SyntaxKind> s_validLocalFunctionModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\FieldKeywordRecommender.cs (1)
16private static readonly ISet<SyntaxKind> s_validTypeDeclarations = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\FileKeywordRecommender.cs (1)
17.Where(s => s != SyntaxKind.FileKeyword && !SyntaxFacts.IsAccessibilityModifier(s))
Completion\KeywordRecommenders\FixedKeywordRecommender.cs (1)
14private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\ImplicitKeywordRecommender.cs (2)
14private static readonly ISet<SyntaxKind> s_validNonInterfaceMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 22private static readonly ISet<SyntaxKind> s_validInterfaceMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\InterfaceKeywordRecommender.cs (1)
14private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\NewKeywordRecommender.cs (2)
17private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 33protected static readonly ISet<SyntaxKind> ValidTypeModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\OverrideKeywordRecommender.cs (1)
14private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\ParamKeywordRecommender.cs (1)
15private static readonly ISet<SyntaxKind> s_validTypeDeclarations = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer);
Completion\KeywordRecommenders\PartialKeywordRecommender.cs (1)
18private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\ReadOnlyKeywordRecommender.cs (1)
16private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\RecordKeywordRecommender.cs (1)
14private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\RefKeywordRecommender.cs (4)
25private static readonly ISet<SyntaxKind> RefMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 47private static readonly ISet<SyntaxKind> RefGlobalMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 65private static readonly ISet<SyntaxKind> RefGlobalMemberScriptModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 105if (token.Kind() == SyntaxKind.IdentifierToken && SyntaxFacts.GetContextualKeywordKind((string)token.Value!) == SyntaxKind.AllowsKeyword &&
Completion\KeywordRecommenders\SealedKeywordRecommender.cs (3)
14private static readonly ISet<SyntaxKind> s_validNonInterfaceMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 25private static readonly ISet<SyntaxKind> s_validInterfaceMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 37private static readonly ISet<SyntaxKind> s_validTypeModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\StaticKeywordRecommender.cs (5)
15private static readonly ISet<SyntaxKind> s_validTypeModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 26private static readonly ISet<SyntaxKind> s_validNonInterfaceMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 40private static readonly ISet<SyntaxKind> s_validInterfaceMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 57private static readonly ISet<SyntaxKind> s_validGlobalMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 69private static readonly ISet<SyntaxKind> s_validLocalFunctionModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\StructKeywordRecommender.cs (1)
15private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\UnsafeKeywordRecommender.cs (4)
14private static readonly ISet<SyntaxKind> s_validTypeModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 27private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 44private static readonly ISet<SyntaxKind> s_validGlobalMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 56private static readonly ISet<SyntaxKind> s_validLocalFunctionModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\UsingKeywordRecommender.cs (2)
146else if (token.Kind() == SyntaxKind.IdentifierToken && SyntaxFacts.GetContextualKeywordKind((string)token.Value!) == SyntaxKind.GlobalKeyword) 158else if (token.Kind() == SyntaxKind.IdentifierToken && SyntaxFacts.GetContextualKeywordKind((string)token.Value!) == SyntaxKind.GlobalKeyword)
Completion\KeywordRecommenders\VirtualKeywordRecommender.cs (2)
14private static readonly ISet<SyntaxKind> s_validNonInterfaceMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 25private static readonly ISet<SyntaxKind> s_validInterfaceMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\VoidKeywordRecommender.cs (2)
15private static readonly ISet<SyntaxKind> s_validClassInterfaceRecordModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 32private static readonly ISet<SyntaxKind> s_validStructModifiers = new HashSet<SyntaxKind>(s_validClassInterfaceRecordModifiers, SyntaxFacts.EqualityComparer)
Completion\KeywordRecommenders\VolatileKeywordRecommender.cs (1)
15private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Completion\Providers\ContextVariableArgumentProvider.cs (1)
26protected override string ThisOrMeKeyword => SyntaxFacts.GetText(SyntaxKind.ThisKeyword);
Completion\Providers\OutVariableArgumentProvider.cs (2)
44if (SyntaxFacts.GetKeywordKind(name) != SyntaxKind.None 45|| SyntaxFacts.GetContextualKeywordKind(name) != SyntaxKind.None)
ConvertToRawString\ConvertInterpolatedStringToRawStringCodeRefactoringProvider.cs (3)
615while (SyntaxFacts.IsNewLine(builder[beforeNewLines - 1])) 619while (SyntaxFacts.IsWhitespace(builder[beforeSpaces - 1])) 678while (current < length && SyntaxFacts.IsWhitespace(leadingWhitespace1[current]) && leadingWhitespace1[current] == leadingWhitespace2[current])
ConvertToRawString\ConvertToRawStringHelpers.cs (2)
33=> ch.Rune.Utf16SequenceLength == 1 && SyntaxFacts.IsNewLine((char)ch.Value); 36=> ch.Rune.Utf16SequenceLength == 1 && SyntaxFacts.IsWhitespace((char)ch.Value);
EditAndContinue\BreakpointSpans.cs (1)
48if (!SyntaxFacts.IsWhitespace(text[i]))
EmbeddedLanguages\CSharpTestEmbeddedLanguageClassifier.cs (1)
77for (var i = lastLine.Start; i < lastLine.End && SyntaxFacts.IsWhitespace(text[i]); i++)
ExtractInterface\CSharpExtractInterfaceService.cs (1)
63return typeDeclaration.Modifiers.Any(m => SyntaxFacts.IsAccessibilityModifier(m.Kind()));
ExtractMethod\CSharpSelectionResult.cs (1)
219if (ancestors.Where(a => CSharp.SyntaxFacts.IsTypeDeclaration(a.Kind()))
GenerateMember\GenerateVariable\CSharpGenerateVariableService.cs (1)
51var contextualKind = SyntaxFacts.GetContextualKeywordKind(token.ValueText);
GenerateType\CSharpGenerateTypeService.cs (4)
141if (SyntaxFacts.IsAliasQualifier(simpleName)) 197if (!SyntaxFacts.IsInNamespaceOrTypeContext(nameOrMemberAccessExpression)) 244!SyntaxFacts.IsInNamespaceOrTypeContext(simpleName)) 283if (SyntaxFacts.IsInNamespaceOrTypeContext(nameOrMemberAccessExpression))
GoToDefinition\CSharpGoToDefinitionSymbolService.cs (3)
97SyntaxFacts.GetTypeDeclarationKind(kind) != SyntaxKind.None) 113SyntaxFacts.GetTypeDeclarationKind(node.Kind()) != SyntaxKind.None) 128if (SyntaxFacts.GetTypeDeclarationKind(node.Kind()) != SyntaxKind.None)
InlineHints\CSharpInlineParameterNameHintsService.cs (2)
102var keywordKind = SyntaxFacts.GetKeywordKind(parameterName); 103var isReservedKeyword = SyntaxFacts.IsReservedKeyword(keywordKind);
InvertLogical\CSharpInvertLogicalCodeRefactoringProvider.cs (2)
26? SyntaxFacts.GetText(SyntaxKind.AmpersandAmpersandToken) 27: SyntaxFacts.GetText(SyntaxKind.BarBarToken);
LanguageServices\CSharpStructuralTypeDisplayService.cs (4)
37members.Add(Keyword(SyntaxFacts.GetText(SyntaxKind.NewKeyword))); 39members.Add(Punctuation(SyntaxFacts.GetText(SyntaxKind.OpenBraceToken))); 47members.Add(Punctuation(SyntaxFacts.GetText(SyntaxKind.CommaToken))); 58members.Add(Punctuation(SyntaxFacts.GetText(SyntaxKind.CloseBraceToken)));
LineSeparators\CSharpLineSeparatorService.cs (1)
72if (SyntaxFacts.IsTypeDeclaration(node.Kind()))
MetadataAsSource\FormattingRule.cs (1)
66=> SyntaxFacts.IsNewLine(c);
ReplaceDocCommentTextWithTag\CSharpReplaceDocCommentTextWithTagCodeRefactoringProvider.cs (4)
30=> SyntaxFacts.IsKeywordKind(SyntaxFacts.GetKeywordKind(text)) || SyntaxFacts.IsContextualKeyword(SyntaxFacts.GetContextualKeywordKind(text));
SignatureHelp\AbstractCSharpSignatureHelpProvider.cs (3)
19=> new SymbolDisplayPart(SymbolDisplayPartKind.Keyword, null, SyntaxFacts.GetText(kind)); 22=> new SymbolDisplayPart(SymbolDisplayPartKind.Operator, null, SyntaxFacts.GetText(kind)); 25=> new SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, null, SyntaxFacts.GetText(kind));
SignatureHelp\GenericNameSignatureHelpProvider.cs (1)
105var namespacesOrTypesOnly = SyntaxFacts.IsInNamespaceOrTypeContext(simpleName);
Snippets\AbstractCSharpAutoPropertySnippetProvider.cs (1)
59if (!syntaxContext.PrecedingModifiers.Any(SyntaxFacts.IsAccessibilityModifier))
Snippets\AbstractCSharpTypeSnippetProvider.cs (2)
52if (tree.GetPrecedingModifiers(position, cancellationToken).Any(SyntaxFacts.IsAccessibilityModifier)) 79return new TextChange(TextSpan.FromBounds(targetPosition, targetPosition), SyntaxFacts.GetText(SyntaxKind.PublicKeyword) + " ");
Snippets\CSharpClassSnippetProvider.cs (1)
25private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Snippets\CSharpConstructorSnippetProvider.cs (2)
30private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 45if (!(precedingModifiers.All(SyntaxFacts.IsAccessibilityModifier) ||
Snippets\CSharpEnumSnippetProvider.cs (1)
25private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Snippets\CSharpInterfaceSnippetProvider.cs (1)
25private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Snippets\CSharpStructSnippetProvider.cs (1)
25private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
src\Analyzers\CSharp\Analyzers\AddBraces\CSharpAddBracesDiagnosticAnalyzer.cs (1)
117SyntaxFacts.GetText(firstToken.Kind())));
src\Analyzers\CSharp\Analyzers\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementDiagnosticAnalyzer.cs (1)
137if (!SyntaxFacts.IsWhitespace(text[i]))
src\Analyzers\CSharp\Analyzers\OrderModifiers\CSharpOrderModifiersHelper.cs (2)
21var kind = SyntaxFacts.GetKeywordKind(trimmed); 22return (int)(kind == SyntaxKind.None ? SyntaxFacts.GetContextualKeywordKind(trimmed) : kind);
src\Analyzers\CSharp\Analyzers\UseCollectionInitializer\CSharpUseCollectionInitializerAnalyzer.cs (1)
182var matchIndex = spreadElements.FindIndex(SyntaxFacts.AreEquivalent, current);
src\Analyzers\CSharp\Analyzers\UseCompoundAssignment\Utilities.cs (1)
31if (SyntaxFacts.GetAssignmentExpression(current) == assignmentExpressionKind)
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs (1)
85Debug.Assert(SyntaxFacts.IsAssignmentExpression(nodeToGenerate));
src\Analyzers\CSharp\CodeFixes\DocumentationComments\CSharpRemoveDocCommentNodeCodeFixProvider.cs (1)
56if (!SyntaxFacts.IsWhitespace(c))
src\Analyzers\CSharp\CodeFixes\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementCodeFixProvider.cs (1)
87if (end < text.Length && SyntaxFacts.IsNewLine(text[end]))
src\Analyzers\CSharp\CodeFixes\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementCodeFixProvider.cs (1)
89if (end < text.Length && SyntaxFacts.IsNewLine(text[end]))
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (1)
291return SyntaxFacts.IsInTypeOnlyContext(originalName)
Structure\Providers\DisabledTextTriviaStructureProvider.cs (1)
73endPos >= 1 && SyntaxFacts.IsNewLine(text[endPos - 1]) ? endPos - 1 : endPos;
TaskList\CSharpTaskListService.cs (3)
66=> SyntaxFacts.IsIdentifierPartCharacter(ch); 73if (!SyntaxFacts.IsWhitespace(ch) && 86SyntaxFacts.IsPreprocessorDirective(trivia.Kind()) && trivia.ToString().IndexOf(SingleLineCommentPrefix, StringComparison.Ordinal) > 0;
UseAutoProperty\CSharpUseAutoPropertyCodeFixProvider.cs (1)
183=> attributeList.WithTarget(AttributeTargetSpecifier(Identifier(SyntaxFacts.GetText(SyntaxKind.FieldKeyword)), ColonToken.WithTrailingTrivia(Space)));
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (1)
EditAndContinue\TopLevelEditingTests.cs (1)
1949Diagnostic(RudeEditKind.ModifiersUpdate, "readonly struct X", SyntaxFacts.GetText(SyntaxKind.StructKeyword)));
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (31)
Semantics\InitOnlyMemberTests.cs (2)
4075Assert.True(SyntaxFacts.IsAccessorDeclaration(SyntaxKind.InitAccessorDeclaration)); 4076Assert.True(SyntaxFacts.IsAccessorDeclarationKeyword(SyntaxKind.InitKeyword));
Semantics\RecordStructTests.cs (2)
384Assert.True(SyntaxFacts.IsTypeDeclaration(SyntaxKind.RecordStructDeclaration)); 486Assert.True(SyntaxFacts.IsTypeDeclaration(SyntaxKind.RecordStructDeclaration));
Semantics\RefFieldTests.cs (27)
12075Assert.True(SyntaxFacts.IsInTypeOnlyContext(type)); 12076Assert.True(SyntaxFacts.IsInTypeOnlyContext(type.SkipScoped(out _))); 12077Assert.True(SyntaxFacts.IsInTypeOnlyContext(type.SkipScoped(out _).SkipRef())); 12209Assert.True(SyntaxFacts.IsInTypeOnlyContext(type)); 12210Assert.True(SyntaxFacts.IsInTypeOnlyContext(type.SkipScoped(out _))); 12211Assert.True(SyntaxFacts.IsInTypeOnlyContext(type.SkipScoped(out _).SkipRef())); 12398Assert.True(SyntaxFacts.IsInTypeOnlyContext(type)); 12399Assert.True(SyntaxFacts.IsInTypeOnlyContext(type.SkipScoped(out _))); 12400Assert.True(SyntaxFacts.IsInTypeOnlyContext(type.SkipScoped(out _).SkipRef())); 12430Assert.True(SyntaxFacts.IsInTypeOnlyContext(type)); 12431Assert.True(SyntaxFacts.IsInTypeOnlyContext(type.SkipScoped(out _))); 12432Assert.True(SyntaxFacts.IsInTypeOnlyContext(type.SkipScoped(out _).SkipRef())); 12809Assert.True(SyntaxFacts.IsInTypeOnlyContext(type)); 12810Assert.True(SyntaxFacts.IsInTypeOnlyContext(type.SkipScoped(out _))); 12811Assert.True(SyntaxFacts.IsInTypeOnlyContext(type.SkipScoped(out _).SkipRef())); 12843Assert.True(SyntaxFacts.IsInTypeOnlyContext(type)); 12844Assert.True(SyntaxFacts.IsInTypeOnlyContext(type.SkipScoped(out _))); 12845Assert.True(SyntaxFacts.IsInTypeOnlyContext(type.SkipScoped(out _).SkipRef())); 14609Assert.True(SyntaxFacts.IsInTypeOnlyContext(type)); 14610Assert.True(SyntaxFacts.IsInTypeOnlyContext(type.SkipScoped(out _))); 14611Assert.True(SyntaxFacts.IsInTypeOnlyContext(type.SkipScoped(out _).SkipRef())); 27058Assert.True(SyntaxFacts.IsInTypeOnlyContext(type)); 27059Assert.True(SyntaxFacts.IsInTypeOnlyContext(type.SkipScoped(out _))); 27060Assert.True(SyntaxFacts.IsInTypeOnlyContext(type.SkipScoped(out _).SkipRef())); 27148Assert.True(SyntaxFacts.IsInTypeOnlyContext(type)); 27149Assert.True(SyntaxFacts.IsInTypeOnlyContext(type.SkipScoped(out _))); 27150Assert.True(SyntaxFacts.IsInTypeOnlyContext(type.SkipScoped(out _).SkipRef()));
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (3)
Compilation\SemanticModelGetSemanticInfoTests.cs (2)
10116Assert.False(SyntaxFacts.IsAttributeName(((SourceNamedTypeSymbol)((CSharp.Symbols.PublicModel.NamedTypeSymbol)semanticInfo.Symbol).UnderlyingNamedTypeSymbol).SyntaxReferences.First().GetSyntax()), 10153Assert.False(SyntaxFacts.IsAttributeName(((SourceNamedTypeSymbol)((CSharp.Symbols.PublicModel.NamedTypeSymbol)semanticInfo.Symbol).UnderlyingNamedTypeSymbol).SyntaxReferences.First().GetSyntax()),
DocumentationComments\DocumentationCommentCompilerTests.cs (1)
3351Assert.True(SyntaxFacts.IsWhitespace(ch));
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (120)
Diagnostics\DiagnosticTest.cs (1)
1886/// See <see cref="SyntaxFacts.IsPreprocessorContextualKeyword"/>.
LexicalAndXml\DocumentationCommentLexerTestBase.cs (3)
81var canonicalText = SyntaxFacts.GetText(token.Kind); 118? SyntaxFacts.GetText(kind) 119: SyntaxFacts.GetText(contextualKind);
LexicalAndXml\LexicalTests.cs (11)
835foreach (var keyword in SyntaxFacts.GetKeywordKinds()) 837if (SyntaxFacts.IsReservedKeyword(keyword)) 839var value = SyntaxFacts.GetText(keyword); 877foreach (var keyword in SyntaxFacts.GetKeywordKinds()) 879if (SyntaxFacts.IsReservedKeyword(keyword)) 881var text = SyntaxFacts.GetText(keyword); 885Assert.True(SyntaxFacts.IsReservedKeyword(token.Kind())); 961var text = SyntaxFacts.GetText(kind); 3742int max = SyntaxFacts 3744.Concat(SyntaxFacts.GetContextualKeywordKinds()) 3745.Select(SyntaxFacts.GetText)
LexicalAndXml\PreprocessorTests.cs (2)
280Assert.True(SyntaxFacts.IsPreprocessorDirective(SyntaxKind.NullableDirectiveTrivia)); 281Assert.True(SyntaxFacts.IsPreprocessorKeyword(SyntaxKind.NullableKeyword));
LexicalAndXml\RawStringLiteralLexingTests.cs (1)
246if (charValue == '"' || SyntaxFacts.IsNewLine(charValue))
LexicalAndXml\XmlDocCommentTests.cs (2)
926Assert.True(SyntaxFacts.IsNewLine('\u0085')); 1204Assert.True(SyntaxFacts.IsNewLine('\u0085'));
Parsing\DeclarationParsingTests.cs (27)
2096var typeText = SyntaxFacts.GetText(builtInType); 2142var typeText = SyntaxFacts.GetText(builtInType); 2670var text = "class a { " + string.Join(" ", modifiers.Select(SyntaxFacts.GetText)) + " b X() { } }"; 3097var text = "class a { b X(" + SyntaxFacts.GetText(mod) + " c d) { } }"; 3235var typeText = SyntaxFacts.GetText(type); 3300var typeText = SyntaxFacts.GetText(type); 3515var text = "class a { " + SyntaxFacts.GetText(mod) + " a() { } }"; 3658var typeText = SyntaxFacts.GetText(type); 3699var text = "class a { " + SyntaxFacts.GetText(mod) + " b c; }"; 3753var text = "class a { " + SyntaxFacts.GetText(mod) + " event b c; }"; 4287var typeText = SyntaxFacts.GetText(type); 4480var text = "class a { " + (isEvent ? "event" : string.Empty) + " b c { " + SyntaxFacts.GetText(accessorKeyword) + " { x = value; } } }"; 4536var text = "class a { event b c { " + SyntaxFacts.GetText(accessorKeyword) + " { x = value; } } }"; 4592var text = "class a { " + SyntaxFacts.GetText(mod) + " b c { get; set; } }"; 4786var text = "class a { " + SyntaxFacts.GetText(mod) + " event b c { add { } remove { } } }"; 5272var text = "class a { b operator " + SyntaxFacts.GetText(op1) + " (c d, e f) { } }"; 5466var text = "class a { b operator " + SyntaxFacts.GetText(op1) + " (c d) { } }"; 9378" + SyntaxFacts.GetText(keywordKind) + @" C;"; 9401" + SyntaxFacts.GetText(keywordKind) + @" C<T>;"; 9433" + SyntaxFacts.GetText(keywordKind) + @" 9471" + SyntaxFacts.GetText(keywordKind) + @" C; 9507" + SyntaxFacts.GetText(keywordKind) + @" C : Base;"; 9541" + SyntaxFacts.GetText(keywordKind) + @" C : Base, I1;"; 9583" + SyntaxFacts.GetText(keywordKind) + @" C where T1 : U1 ;"; 9622" + SyntaxFacts.GetText(keywordKind) + @" C where T1 : U1 where T2 : U2 ;"; 9677" + SyntaxFacts.GetText(keywordKind) + @" C<T1> where T1 : U1 ;"; 9726" + SyntaxFacts.GetText(keywordKind) + @" C { };";
Parsing\ExpressionParsingTests.cs (16)
452var text = SyntaxFacts.GetText(kind); 456var opKind = SyntaxFacts.GetLiteralExpression(kind); 475var text = SyntaxFacts.GetText(kind); 479var opKind = SyntaxFacts.GetInstanceExpression(kind); 565var text = SyntaxFacts.GetText(kind) + "a"; 569var opKind = SyntaxFacts.GetPrefixUnaryExpression(kind); 596var text = "a" + SyntaxFacts.GetText(kind); 600var opKind = SyntaxFacts.GetPostfixUnaryExpression(kind); 622var text = "(a) " + SyntaxFacts.GetText(kind) + " b"; 626var opKind = SyntaxFacts.GetBinaryExpression(kind); 668var text = "(a) " + SyntaxFacts.GetText(kind) + " b"; 672var opKind = SyntaxFacts.GetAssignmentExpression(kind); 705var text = "(a)" + SyntaxFacts.GetText(kind) + " b"; 812var text = SyntaxFacts.GetText(kind) + "(a)"; 816var opKind = SyntaxFacts.GetPrimaryFunction(kind); 876var text = SyntaxFacts.GetText(SyntaxKind.RefValueKeyword) + "(a, b)";
Parsing\FileModifierParsingTests.cs (12)
50file {{SyntaxFacts.GetText(typeKeyword)}} C { } 54N(SyntaxFacts.GetBaseTypeDeclarationKind(typeKeyword)); 75file partial {{SyntaxFacts.GetText(typeKeyword)}} C { } 79N(SyntaxFacts.GetBaseTypeDeclarationKind(typeKeyword)); 128partial file {{SyntaxFacts.GetText(typeKeyword)}} C { } 134Diagnostic(ErrorCode.ERR_SemicolonExpected, SyntaxFacts.GetText(typeKeyword)).WithLocation(1, 14) 146Diagnostic(ErrorCode.ERR_SemicolonExpected, SyntaxFacts.GetText(typeKeyword)).WithLocation(1, 14) 168N(SyntaxFacts.GetBaseTypeDeclarationKind(typeKeyword)); 502public file {{SyntaxFacts.GetText(typeKeyword)}} C { } 512N(SyntaxFacts.GetBaseTypeDeclarationKind(typeKeyword)); 535file public {{SyntaxFacts.GetText(typeKeyword)}} C { } 545N(SyntaxFacts.GetBaseTypeDeclarationKind(typeKeyword));
Parsing\FunctionPointerTests.cs (3)
4065Assert.True(CSharp.SyntaxFacts.IsTypeSyntax(SyntaxKind.FunctionPointerType)); 4066Assert.True(CSharp.SyntaxFacts.IsContextualKeyword(SyntaxKind.ManagedKeyword)); 4067Assert.True(CSharp.SyntaxFacts.IsContextualKeyword(SyntaxKind.UnmanagedKeyword));
Parsing\ImplicitObjectCreationParsingTests.cs (2)
310UsingExpression($"new(Int32,Int32){SyntaxFacts.GetText(tokenKind),3}", DefaultParseOptions, 349UsingExpression($"new(Int32,Int32){SyntaxFacts.GetText(tokenKind),2}e", DefaultParseOptions);
Parsing\NameParsingTests.cs (13)
473var text = SyntaxFacts.GetText(kind); 786Assert.True(SyntaxFacts.ContainsDroppedIdentifierCharacters(text)); 787Assert.False(SyntaxFacts.ContainsDroppedIdentifierCharacters(tok.ValueText)); 802Assert.True(SyntaxFacts.ContainsDroppedIdentifierCharacters(text)); 803Assert.False(SyntaxFacts.ContainsDroppedIdentifierCharacters(tok.ValueText)); 810Assert.False(SyntaxFacts.ContainsDroppedIdentifierCharacters(null)); 811Assert.False(SyntaxFacts.ContainsDroppedIdentifierCharacters("")); 812Assert.False(SyntaxFacts.ContainsDroppedIdentifierCharacters("a")); 813Assert.False(SyntaxFacts.ContainsDroppedIdentifierCharacters("a@")); 815Assert.True(SyntaxFacts.ContainsDroppedIdentifierCharacters("@")); 816Assert.True(SyntaxFacts.ContainsDroppedIdentifierCharacters("@a")); 817Assert.True(SyntaxFacts.ContainsDroppedIdentifierCharacters("\u200d")); 818Assert.True(SyntaxFacts.ContainsDroppedIdentifierCharacters("a\u200d"));
Parsing\ParsingErrorRecoveryTests.cs (1)
88var accessibilityKind = SyntaxFacts.GetKeywordKind(accessibility);
Parsing\PatternParsingTests.cs (3)
10855UsingStatement($"_ = e is (int){left} {SyntaxFacts.GetText(opKind)} {right};", 10972UsingStatement($"_ = e is {left} {SyntaxFacts.GetText(opKind)} {right};", 11023UsingStatement($"_ = e is (int) {SyntaxFacts.GetText(opKind)} {right};",
Parsing\StatementParsingTests.cs (3)
153var text = "a" + SyntaxFacts.GetText(kind) + ";"; 166var opKind = SyntaxFacts.GetPostfixUnaryExpression(kind); 3341var keywordText = SyntaxFacts.GetText(kind);
Syntax\SyntaxFactoryTests.cs (4)
193if (!SyntaxFacts.IsAnyToken(kind)) continue; 195var defaultText = SyntaxFacts.GetText(kind); 210if (!SyntaxFacts.IsAnyToken(kind)) continue; 212var defaultText = SyntaxFacts.GetText(kind);
Syntax\SyntaxRewriterTests.cs (1)
592return SyntaxFacts.IsStatementExpression(expression);
Syntax\SyntaxTests.cs (15)
183var actual = SyntaxFacts.TryGetInferredMemberName(expr); 201Assert.Equal(isReserved, SyntaxFacts.IsReservedTupleElementName(elementName)); 215Assert.True(SyntaxFacts.IsLiteral(kind)); 229Assert.True(SyntaxFacts.IsAnyToken(kind)); 244Assert.Equal(expressionKind, SyntaxFacts.GetLiteralExpression(tokenKind)); 250foreach (var kind in SyntaxFacts.GetPunctuationKinds()) 252Assert.True(SyntaxFacts.IsPunctuation(kind)); 273Assert.True(SyntaxFacts.IsAttributeTargetSpecifier(kind), $$"""IsAttributeTargetSpecific({{kind}}) should be true"""); 277Assert.False(SyntaxFacts.IsAttributeTargetSpecifier(kind), $$"""IsAttributeTargetSpecific({{kind}}) should be false"""); 286foreach (var method in typeof(SyntaxFacts).GetMethods(BindingFlags.Public | BindingFlags.Static)) 299[InlineData(nameof(SyntaxFacts.GetContextualKeywordKinds), SyntaxKind.YieldKeyword, SyntaxKind.ElifKeyword)] 300[InlineData(nameof(SyntaxFacts.GetPunctuationKinds), SyntaxKind.TildeToken, SyntaxKind.BoolKeyword)] 301[InlineData(nameof(SyntaxFacts.GetReservedKeywordKinds), SyntaxKind.BoolKeyword, SyntaxKind.YieldKeyword)] 304var method = typeof(SyntaxFacts).GetMethod(methodName, BindingFlags.Public | BindingFlags.Static); 331var returnedKindsInts = SyntaxFacts.GetPreprocessorKeywordKinds().Select(static k => (int)k).ToHashSet();
Microsoft.CodeAnalysis.CSharp.Workspaces (95)
Classification\ClassificationHelpers.cs (4)
34else if (SyntaxFacts.IsKeywordKind(token.Kind()) || token.IsKind(SyntaxKind.DiscardDesignation)) 39else if (SyntaxFacts.IsPunctuation(token.Kind())) 542var isKeyword = SyntaxFacts.IsKeywordKind(token.Kind()) 543|| (wasKeyword && SyntaxFacts.GetContextualKeywordKind(text) != SyntaxKind.None)
CodeGeneration\CSharpSyntaxGenerator.cs (3)
299checkedKeyword: CSharp.SyntaxFacts.IsCheckedOperator(operatorName) ? CheckedKeyword : default, 307var operatorKind = CSharp.SyntaxFacts.GetOperatorKind(operatorName); 2214if (!rewrittenToken.IsMissing || !CSharp.SyntaxFacts.IsPunctuationOrKeyword(token.Kind()))
LanguageServices\FixAllSpanMappingService\CSharpFixAllSpanMappingService.cs (1)
40var firstTypeOrNamespaceDecl = root.ChildNodes().FirstOrDefault(n => SyntaxFacts.IsNamespaceMemberDeclaration(n.Kind()));
Rename\CSharpRenameRewriterLanguageService.cs (6)
574var isAttributeName = SyntaxFacts.IsAttributeName(parent); 601var kind = SyntaxFacts.GetKeywordKind(currentNewIdentifier); 604valueText = SyntaxFacts.GetText(kind); 1123var kind = SyntaxFacts.GetKeywordKind(replacementText); 1126valueText = SyntaxFacts.GetText(kind); 1279var isInNamespaceOrTypeContext = SyntaxFacts.IsInNamespaceOrTypeContext(node as ExpressionSyntax);
Simplification\CSharpSimplificationService.cs (3)
103if (SyntaxFacts.GetKeywordKind(syntaxToken.ValueText) == SyntaxKind.None && SyntaxFacts.GetContextualKeywordKind(syntaxToken.ValueText) == SyntaxKind.None) 108if (SyntaxFacts.GetContextualKeywordKind(syntaxToken.ValueText) == SyntaxKind.UnderscoreToken)
Simplification\CSharpSimplificationService.Expander.cs (3)
288if (name == null || SyntaxFacts.IsReservedTupleElementName(name)) 455if (!SyntaxFacts.IsAliasQualifier(originalSimpleName)) 976if (SyntaxFacts.IsInNamespaceOrTypeContext(originalNode))
Simplification\Reducers\CSharpEscapingReducer.cs (4)
43if (SyntaxFacts.GetKeywordKind(unescapedIdentifier) != SyntaxKind.None && enclosingXmlNameAttr == null) 53if (SyntaxFacts.GetContextualKeywordKind(unescapedIdentifier) == SyntaxKind.AwaitKeyword) 86switch (SyntaxFacts.GetContextualKeywordKind(unescapedIdentifier)) 111if (SyntaxFacts.IsAttributeName(parent))
Simplification\Simplifiers\AbstractCSharpSimplifier.cs (1)
410!SyntaxFacts.IsInNamespaceOrTypeContext(expression))
Simplification\Simplifiers\MemberAccessExpressionSimplifier.cs (1)
75(CSharp.SyntaxFacts.IsKeywordKind(nextToken.Kind()) && nextToken.Kind() is not SyntaxKind.AsKeyword and not SyntaxKind.IsKeyword))
Simplification\Simplifiers\NameSimplifier.cs (2)
494if (SyntaxFacts.IsAttributeName(name)) 506if (SyntaxFacts.GetKeywordKind(newAttributeName) != SyntaxKind.None)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CodeStyle\CSharpCodeStyleOptions.cs (1)
172defaultValue: new CodeStyleOption2<string>(string.Join(",", s_preferredModifierOrderDefault.Select(SyntaxFacts.GetText)), NotificationOption2.Silent));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CodeStyle\TypeStyle\TypeStyleHelper.cs (1)
225? SyntaxFacts.IsPredefinedType(predefinedType.Keyword.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ExpressionSyntaxExtensions.cs (1)
428name.Identifier.Text == SyntaxFacts.GetText(SyntaxKind.NameOfKeyword))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (1)
444if (SyntaxFacts.GetContextualKeywordKind(parameter.Name) is not SyntaxKind.UnderscoreToken)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SymbolDisplayPartExtensions.cs (1)
21if (SyntaxFacts.GetKeywordKind(text) != SyntaxKind.None)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (1)
603var hasLeadingDirective = node.GetLeadingTrivia().Any(t => SyntaxFacts.IsPreprocessorDirective(t.Kind()));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTokenExtensions.cs (3)
43=> token.ToString() == SyntaxFacts.GetText(kind); 70SyntaxFacts.GetContextualKeywordKind(simpleNameText) != SyntaxKind.None; 330if (SyntaxFacts.IsKeywordKind(token.Kind()))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTreeExtensions.cs (1)
30var result = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\CSharpTriviaFormatter.cs (3)
44=> SyntaxFacts.IsWhitespace(ch); 47=> SyntaxFacts.IsNewLine(ch); 87if (SyntaxFacts.IsPreprocessorDirective(trivia2.Kind()))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaDataFactory.Analyzer.cs (1)
128Contract.ThrowIfFalse(SyntaxFacts.IsPreprocessorDirective(trivia.Kind()));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaDataFactory.CodeShapeAnalyzer.cs (3)
67SyntaxFacts.IsPreprocessorDirective(trivia.Kind())) 248if (!SyntaxFacts.IsPreprocessorDirective(trivia.Kind())) 314if (!string.IsNullOrEmpty(triviaString) && SyntaxFacts.IsNewLine(triviaString.Last()))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaDataFactory.cs (2)
27=> SyntaxFacts.IsWhitespace(c) || SyntaxFacts.IsNewLine(c);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (1)
487=> triviaList.Sum(t => t.ToFullString().Replace("\r\n", "\r").Cast<char>().Count(c => SyntaxFacts.IsNewLine(c)));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\StructuredTriviaFormattingRule.cs (1)
29if (previousToken.Kind() == SyntaxKind.HashToken && SyntaxFacts.IsPreprocessorKeyword(currentToken.Kind()))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (15)
89var needsEscaping = SyntaxFacts.GetKeywordKind(identifier) != SyntaxKind.None; 101(SyntaxFacts.IsAnyUnaryExpression(kind) && 103(SyntaxFacts.IsBinaryExpression(kind) && (token.Parent is BinaryExpressionSyntax or OperatorDeclarationSyntax or RelationalPatternSyntax)) || 104(SyntaxFacts.IsAssignmentExpressionOperatorToken(kind) && token.Parent is AssignmentExpressionSyntax); 108=> SyntaxFacts.IsReservedKeyword(token.Kind()); 111=> SyntaxFacts.IsContextualKeyword(token.Kind()); 114=> SyntaxFacts.IsPreprocessorKeyword(token.Kind()); 447=> SyntaxFacts.GetText((SyntaxKind)kind); 450=> SyntaxFacts.IsIdentifierStartCharacter(c); 453=> SyntaxFacts.IsIdentifierPartCharacter(c); 584=> SyntaxFacts.IsInNamespaceOrTypeContext(node as ExpressionSyntax); 1229=> SyntaxFacts.IsDocumentationCommentTrivia(node.Kind()); 1250if (SyntaxFacts.IsNamespaceMemberDeclaration(node.Kind())) 1295=> SyntaxFacts.IsTypeDeclaration(node.Kind()); 1370=> SyntaxFacts.IsPreprocessorDirective(trivia.Kind());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (2)
119var isInNamespaceOrTypeContext = SyntaxFacts.IsInNamespaceOrTypeContext(originalNode as ExpressionSyntax); 646=> SyntaxFacts.IsInNamespaceOrTypeContext(node);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpTypeStyleHelper.State.cs (1)
89/// to var. <see cref="SyntaxFacts.IsPredefinedType(SyntaxKind)"/> considers string
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\ConversionGenerator.cs (1)
63var checkedToken = SyntaxFacts.IsCheckedOperator(method.MetadataName)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (1)
749modifier => SyntaxFacts.IsAccessibilityModifier(modifier.Kind()));
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpDeclarationComparer.cs (2)
15private static readonly Dictionary<SyntaxKind, int> s_kindPrecedenceMap = new(SyntaxFacts.EqualityComparer) 36private static readonly Dictionary<SyntaxKind, int> s_operatorPrecedenceMap = new(SyntaxFacts.EqualityComparer)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpFlagsEnumGenerator.cs (1)
39=> SyntaxFacts.IsValidIdentifier(name);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\OperatorGenerator.cs (2)
81var operatorSyntaxKind = SyntaxFacts.GetOperatorKind(method.MetadataName); 88var checkedToken = SyntaxFacts.IsCheckedOperator(method.MetadataName)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (1)
699SyntaxFacts.IsInTypeOnlyContext(typedParent) &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (2)
20private static readonly ISet<SyntaxKind> s_validLocalFunctionModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 2879if (token.Text == SyntaxFacts.GetText(SyntaxKind.AsyncKeyword))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\StringExtensions.cs (3)
23var needsEscaping = SyntaxFacts.GetKeywordKind(identifier) != SyntaxKind.None; 26needsEscaping = needsEscaping || (isQueryContext && SyntaxFacts.IsQueryContextualKeyword(SyntaxFacts.GetContextualKeywordKind(identifier)));
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\SyntaxTreeExtensions.cs (1)
149if (SyntaxFacts.IsKeywordKind(token.Kind()))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Utilities\CSharpSimplificationHelpers.cs (3)
23if (SyntaxFacts.GetKeywordKind(syntaxToken.ValueText) == SyntaxKind.None && SyntaxFacts.GetContextualKeywordKind(syntaxToken.ValueText) == SyntaxKind.None) 28if (SyntaxFacts.GetContextualKeywordKind(syntaxToken.ValueText) == SyntaxKind.UnderscoreToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Utilities\SyntaxKindSet.cs (11)
11public static readonly ISet<SyntaxKind> AllTypeModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 27public static readonly ISet<SyntaxKind> AllMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 47public static readonly ISet<SyntaxKind> AllGlobalMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 61public static readonly ISet<SyntaxKind> AccessibilityModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 69public static readonly ISet<SyntaxKind> AllTypeDeclarations = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 79public static readonly ISet<SyntaxKind> ClassInterfaceStructRecordTypeDeclarations = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 88public static readonly ISet<SyntaxKind> ClassInterfaceRecordTypeDeclarations = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 95public static readonly ISet<SyntaxKind> ClassRecordTypeDeclarations = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 101public static readonly ISet<SyntaxKind> ClassStructRecordTypeDeclarations = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 109public static readonly ISet<SyntaxKind> StructOnlyTypeDeclarations = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer) 115public static readonly ISet<SyntaxKind> InterfaceOnlyTypeDeclarations = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
Microsoft.CodeAnalysis.LanguageServer.Protocol (1)
Handler\Formatting\FormatDocumentOnTypeHandler.cs (1)
49if (string.IsNullOrEmpty(request.Character) || SyntaxFacts.IsNewLine(request.Character[0]))
Microsoft.Extensions.Logging.Generators (1)
src\libraries\Common\src\Roslyn\CSharpSyntaxHelper.cs (1)
24=> SyntaxFacts.IsValidIdentifier(name);
Microsoft.ML.InternalCodeAnalyzer (1)
ContractsCheckNameofFixProvider.cs (1)
47if (nameArgValue == null || !SyntaxFacts.IsValidIdentifier(nameArgValue))
System.Text.Json.SourceGeneration (3)
Helpers\RoslynExtensions.cs (2)
227=> SyntaxFacts.GetKeywordKind(symbol.Name) != SyntaxKind.None || SyntaxFacts.GetContextualKeywordKind(symbol.Name) != SyntaxKind.None;
JsonSourceGenerator.Parser.cs (1)
1628if (SyntaxFacts.IsValidIdentifier(effectiveJsonPropertyName))