361 references to Type
Microsoft.CodeAnalysis.CSharp (21)
Binder\Binder_Statements.cs (2)
709var typeSyntax = node.Declaration.Type; 2839var typeSyntax = nodeOpt.Type;
Binder\FixedStatementBinder.cs (1)
35_syntax.Declaration.Type.VisitRankSpecifiers((rankSpecifier, args) =>
Binder\ForLoopBinder.cs (2)
35_syntax.Declaration.Type.VisitRankSpecifiers((rankSpecifier, args) => 75var type = _syntax.Declaration.Type.SkipScoped(out _);
Binder\LocalBinderFactory.cs (4)
563VisitRankSpecifiers(declarationSyntax.Type, usingBinder); 603VisitRankSpecifiers(declaration.Type, binder); 701VisitRankSpecifiers(node.Declaration.Type, binder); 937VisitRankSpecifiers(node.Declaration.Type, _enclosing);
Binder\LocalScopeBinder.cs (2)
191decl.Declaration.Type.VisitRankSpecifiers((rankSpecifier, args) => 338declaration.Type,
Binder\UsingStatementBinder.cs (1)
45declarationSyntax.Type.VisitRankSpecifiers((rankSpecifier, args) =>
Symbols\Source\SourceFieldLikeEventSymbol.cs (1)
41_type = BindEventType(binder, declarationSyntax.Type, declaratorDiagnostics);
Symbols\Source\SourceMemberContainerSymbol.cs (1)
5512_ = fieldSyntax.Declaration.Type.SkipScoped(out _).SkipRefInField(out var refKind);
Symbols\Source\SourceMemberFieldSymbol.cs (2)
392return GetFieldDeclaration(VariableDeclaratorNode).Declaration.Type; 458var typeSyntax = fieldSyntax.Declaration.Type;
Syntax.xml.Main.Generated.cs (1)
1840=> node.Update((TypeSyntax?)Visit(node.Type) ?? throw new ArgumentNullException("type"), VisitList(node.Variables));
Syntax.xml.Syntax.Generated.cs (2)
6582if (type != this.Type || variables != this.Variables) 6593public VariableDeclarationSyntax WithVariables(SeparatedSyntaxList<VariableDeclaratorSyntax> variables) => Update(this.Type, variables);
Syntax\SyntaxFacts.cs (1)
129return ((VariableDeclarationSyntax)parent).Type == node;
Syntax\SyntaxNodeExtensions.cs (1)
271(current.Parent is VariableDeclarationSyntax { Parent: LocalDeclarationStatementSyntax } variableDeclaration && variableDeclaration.Type == current));
Microsoft.CodeAnalysis.CSharp.CodeStyle (20)
src\Analyzers\CSharp\Analyzers\UseDeconstruction\CSharpUseDeconstructionDiagnosticAnalyzer.cs (1)
115semanticModel, local, variableDeclaration.Type, declarator.Identifier, initializerConversion, searchScope,
src\Analyzers\CSharp\Analyzers\UseImplicitObjectCreation\CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs (3)
87Parent: VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Type.IsVar: false } variableDeclaration } 90typeNode = variableDeclaration.Type; 127typeNode = arrayVariableDeclaration.Type is ArrayTypeSyntax arrayType ? arrayType.ElementType : null;
src\Analyzers\CSharp\Analyzers\UseLocalFunction\CSharpUseLocalFunctionDiagnosticAnalyzer.cs (1)
125if (localDeclaration.Declaration.Type.IsVar)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\DefaultExpressionSyntaxExtensions.cs (1)
72return declaration.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ExpressionSyntaxExtensions.cs (2)
337if (refParent.Parent is EqualsValueClauseSyntax { Parent: VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Type: { } variableDeclarationType } } }) 988if (equalsValue.Parent is VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Type.IsVar: true } })
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\MemberDeclarationSyntaxExtensions.cs (2)
169return ((EventFieldDeclarationSyntax)member).Declaration.Type; 171return ((FieldDeclarationSyntax)member).Declaration.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ParenthesizedExpressionSyntaxExtensions.cs (2)
75if (semanticModel.GetTypeInfo(varDecl.Type, cancellationToken).Type.IsSpanOrReadOnlySpan()) 76return !varDecl.Type.IsVar;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\VariableDeclaratorExtensions.cs (1)
17return variableDeclaration.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (1)
1331=> ((VariableDeclarationSyntax)((VariableDeclaratorSyntax)node).Parent!).Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpTypeStyleHelper.cs (1)
88? variableDeclaration.Type
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpTypeStyleHelper.State.cs (2)
78var declaredTypeSymbol = semanticModel.GetTypeInfo(variableDeclaration.Type.StripRefIfNeeded(), cancellationToken).Type; 142VariableDeclarationSyntax varDecl => varDecl.Type,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseExplicitTypeHelper.cs (1)
43if (!variableDeclaration.Type.StripRefIfNeeded().IsVar)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (2)
50var type = variableDeclaration.Type.StripRefIfNeeded(); 129if (!variableDeclaration.Type.IsKind(SyntaxKind.PointerType) &&
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (23)
src\Analyzers\CSharp\CodeFixes\InlineDeclaration\CSharpInlineDeclarationCodeFixProvider.cs (3)
204declaration.Type, 232var explicitType = declaration.Type.IsVar ? local.Type?.GenerateTypeSyntax() : declaration.Type;
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (4)
164return variableDeclaration.Variables.Count == 1 ? variableDeclaration.Type : null; 177return declaration.Type; 188return declaration.Type; 250return declarationSyntax.Type;
src\Analyzers\CSharp\CodeFixes\RemoveUnusedParametersAndValues\CSharpRemoveUnusedValuesCodeFixProvider.cs (1)
63type: parent.Type,
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\CSharpUseConditionalExpressionForAssignmentCodeFixProvider.cs (1)
42statement.Declaration.Type.WithAdditionalAnnotations(Simplifier.Annotation)));
src\Analyzers\CSharp\CodeFixes\UseDeconstruction\CSharpUseDeconstructionCodeFixProvider.cs (1)
140CreateTupleOrDeclarationExpression(tupleType, declarationStatement.Declaration.Type),
src\Analyzers\CSharp\CodeFixes\UseExplicitTypeForConst\UseExplicitTypeForConstCodeFixProvider.cs (2)
46var type = semanticModel.GetTypeInfo(variableDeclaration.Type, cancellationToken).ConvertedType; 67var newRoot = root.ReplaceNode(variableDeclaration.Type, type.GenerateTypeSyntax(allowVar: false));
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (1)
124varDecl.Type,
src\Analyzers\CSharp\CodeFixes\UseSystemThreadingLock\CSharpUseSystemThreadingLockCodeFixProvider.cs (2)
104variableDeclaration.Type, 105lockTypeExpression.WithTriviaFrom(variableDeclaration.Type));
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (2)
890.WithLeadingTrivia(variableDeclarationSyntax.Type.GetLeadingTrivia()) 891.WithTrailingTrivia(variableDeclarationSyntax.Type.GetTrailingTrivia());
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ExpressionSyntaxExtensions.cs (2)
173name.IsFoundUnder<LocalDeclarationStatementSyntax>(d => d.Declaration.Type) || 174name.IsFoundUnder<FieldDeclarationSyntax>(d => d.Declaration.Type))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpMoveDeclarationNearReferenceService.cs (1)
57var type = declarationStatement.Declaration.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpReplaceDiscardDeclarationsWithAssignmentsService.cs (3)
196var leadingTrivia = _localDeclarationStatement.Declaration.Type.GetLeadingTrivia() 197.Concat(_localDeclarationStatement.Declaration.Type.GetTrailingTrivia()); 233VariableDeclaration(_localDeclarationStatement.Declaration.Type, _currentNonDiscardVariables))
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (24)
Semantics\ExtensionTests.cs (24)
39992AssertEx.Equal("System.Action", model.GetTypeInfo(localDeclaration.Type).Type.ToTestDisplayString()); 40018Assert.True(model.GetTypeInfo(localDeclaration.Type).Type.IsErrorType()); 40041Assert.True(model.GetTypeInfo(localDeclaration.Type).Type.IsErrorType()); 40067AssertEx.Equal("System.Action", model.GetTypeInfo(localDeclaration.Type).Type.ToTestDisplayString()); 40091AssertEx.Equal("System.Action", model.GetTypeInfo(localDeclaration.Type).Type.ToTestDisplayString()); 40117Assert.True(model.GetTypeInfo(localDeclaration.Type).Type.IsErrorType()); 40143Assert.True(model.GetTypeInfo(localDeclaration.Type).Type.IsErrorType()); 40167AssertEx.Equal("System.Action", model.GetTypeInfo(localDeclaration.Type).Type.ToTestDisplayString()); 40192AssertEx.Equal("System.Action", model.GetTypeInfo(localDeclaration.Type).Type.ToTestDisplayString()); 40236Assert.True(model.GetTypeInfo(localDeclaration.Type).Type.IsErrorType()); 40277AssertEx.Equal("System.Action<System.Int32>", model.GetTypeInfo(localDeclaration.Type).Type.ToTestDisplayString()); 40392Assert.Equal("?", model.GetTypeInfo(localDeclaration.Type).Type.ToTestDisplayString()); 40417Assert.Equal("System.Int32", model.GetTypeInfo(localDeclaration.Type).Type.ToTestDisplayString()); 46123AssertEx.Equal("System.Action?", model.GetTypeInfo(localDeclaration1.Type).Type.ToTestDisplayString()); 46129AssertEx.Equal("System.Action?", model.GetTypeInfo(localDeclaration2.Type).Type.ToTestDisplayString()); 46164AssertEx.Equal("System.Action?", model.GetTypeInfo(localDeclaration1.Type).Type.ToTestDisplayString()); 46170AssertEx.Equal("System.Action?", model.GetTypeInfo(localDeclaration2.Type).Type.ToTestDisplayString()); 46232AssertEx.Equal("System.Func<System.Object>?", model.GetTypeInfo(varDeclaration1.Type).Type.ToTestDisplayString(includeNonNullable: true)); 46240AssertEx.Equal("System.Func<System.Object>?", model.GetTypeInfo(varDeclaration2.Type).Type.ToTestDisplayString(includeNonNullable: true)); 46256AssertEx.Equal("System.Func<System.Object>?", model.GetTypeInfo(varDeclaration3.Type).Type.ToTestDisplayString(includeNonNullable: true)); 46368AssertEx.Equal("System.Func<System.Object>?", model.GetTypeInfo(localDeclaration1.Type).Type.ToTestDisplayString(includeNonNullable: true)); 46376AssertEx.Equal("System.Func<System.Object>?", model.GetTypeInfo(localDeclaration2.Type).Type.ToTestDisplayString(includeNonNullable: true)); 46468AssertEx.Equal("System.Func<System.Object!>?", model.GetTypeInfo(varDeclaration1.Type).Type.ToTestDisplayString(includeNonNullable: true)); 46475AssertEx.Equal("System.Func<System.Object!>?", model.GetTypeInfo(varDeclaration2.Type).Type.ToTestDisplayString(includeNonNullable: true));
Microsoft.CodeAnalysis.CSharp.Features (47)
CodeRefactorings\InlineTemporary\InlineTemporaryCodeRefactoringProvider.cs (2)
69if (variableDeclaration.Type.Kind() == SyntaxKind.RefType) 450var isVar = ((VariableDeclarationSyntax)variableDeclarator.Parent).Type.IsVar;
Completion\CompletionProviders\DeclarationName\DeclarationNameInfo.cs (3)
320v => v.Type, 359typeSyntaxGetter: v => v.Type, 398typeSyntaxGetter: v => v.Type,
ConvertLinq\ConvertForEachToLinqQuery\AbstractToMethodConverter.cs (1)
156SyntaxNodeOrTokenExtensions.GetTrivia(localDeclaration.Declaration.Type),
ConvertLinq\ConvertForEachToLinqQuery\CSharpConvertForEachToLinqQueryProvider.cs (2)
185localDeclarationStatement.Declaration.Type.GetLeadingTrivia(), 186localDeclarationStatement.Declaration.Type.GetTrailingTrivia() }.Flatten();
ConvertLinq\CSharpConvertLinqQueryToForEachProvider.cs (1)
471((VariableDeclarationSyntax)variableDeclarator.Parent).Type,
EditAndContinue\BreakpointSpans.cs (2)
637return CreateSpan(default, forStatement.Declaration.Type, firstVariable); 868return modifiers.Concat(getDescendantTokens(variableDeclaration.Type)).Concat(getDescendantTokens(variableDeclarator));
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.CallSiteContainerRewriter.cs (1)
117node.Declaration.Type,
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.cs (2)
673declarationStatement.Declaration.Type, 763var typeSyntax = declarationStatement.Declaration.Type;
ExtractMethod\CSharpMethodExtractor.PostProcessor.cs (3)
122var type = _semanticModel.GetSpeculativeTypeInfo(_contextPosition, statement.Declaration.Type, SpeculativeBindingOption.BindAsTypeOrNamespace).Type; 149VariableDeclaration(keyValuePair.Value.First().Declaration.Type, [.. variables])); 187var semanticInfo = _semanticModel.GetSpeculativeTypeInfo(_contextPosition, declarationStatement.Declaration.Type, SpeculativeBindingOption.BindAsTypeOrNamespace).Type;
ExtractMethod\CSharpSelectionResult.ExpressionResult.cs (1)
61return (model.GetTypeInfo(variableDeclExpression.Type, cancellationToken).Type, returnsByRef: false);
InlineHints\CSharpInlineTypeHintsService.cs (3)
33if (node is VariableDeclarationSyntax { Type.IsVar: true } variableDeclaration && 37var type = semanticModel.GetTypeInfo(variableDeclaration.Type, cancellationToken).Type; 39return CreateTypeHint(type, variableDeclaration.Type, variableDeclaration.Variables[0].Identifier);
QuickInfo\CSharpSemanticQuickInfoProvider.cs (1)
187Parent: VariableDeclarationSyntax { Type.IsVar: true },
Rename\CSharpRenameIssuesService.cs (2)
64declaredType = varDecl.Type; 68declaredType = fieldDecl.Declaration.Type;
ReplaceConditionalWithStatements\CSharpReplaceConditionalWithStatementsCodeRefactoringProvider.cs (2)
43if (localDeclarationStatement.Declaration.Type is RefTypeSyntax) 70var type = localDeclarationStatement.Declaration.Type;
SolutionExplorer\CSharpSolutionExplorerSymbolTreeItemProvider.cs (1)
204AppendType(fieldDeclaration.Declaration.Type, nameBuilder);
src\Analyzers\CSharp\Analyzers\UseDeconstruction\CSharpUseDeconstructionDiagnosticAnalyzer.cs (1)
115semanticModel, local, variableDeclaration.Type, declarator.Identifier, initializerConversion, searchScope,
src\Analyzers\CSharp\Analyzers\UseImplicitObjectCreation\CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs (3)
87Parent: VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Type.IsVar: false } variableDeclaration } 90typeNode = variableDeclaration.Type; 127typeNode = arrayVariableDeclaration.Type is ArrayTypeSyntax arrayType ? arrayType.ElementType : null;
src\Analyzers\CSharp\Analyzers\UseLocalFunction\CSharpUseLocalFunctionDiagnosticAnalyzer.cs (1)
125if (localDeclaration.Declaration.Type.IsVar)
src\Analyzers\CSharp\CodeFixes\InlineDeclaration\CSharpInlineDeclarationCodeFixProvider.cs (3)
204declaration.Type, 232var explicitType = declaration.Type.IsVar ? local.Type?.GenerateTypeSyntax() : declaration.Type;
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (4)
164return variableDeclaration.Variables.Count == 1 ? variableDeclaration.Type : null; 177return declaration.Type; 188return declaration.Type; 250return declarationSyntax.Type;
src\Analyzers\CSharp\CodeFixes\RemoveUnusedParametersAndValues\CSharpRemoveUnusedValuesCodeFixProvider.cs (1)
63type: parent.Type,
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\CSharpUseConditionalExpressionForAssignmentCodeFixProvider.cs (1)
42statement.Declaration.Type.WithAdditionalAnnotations(Simplifier.Annotation)));
src\Analyzers\CSharp\CodeFixes\UseDeconstruction\CSharpUseDeconstructionCodeFixProvider.cs (1)
140CreateTupleOrDeclarationExpression(tupleType, declarationStatement.Declaration.Type),
src\Analyzers\CSharp\CodeFixes\UseExplicitTypeForConst\UseExplicitTypeForConstCodeFixProvider.cs (2)
46var type = semanticModel.GetTypeInfo(variableDeclaration.Type, cancellationToken).ConvertedType; 67var newRoot = root.ReplaceNode(variableDeclaration.Type, type.GenerateTypeSyntax(allowVar: false));
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (1)
124varDecl.Type,
src\Analyzers\CSharp\CodeFixes\UseSystemThreadingLock\CSharpUseSystemThreadingLockCodeFixProvider.cs (2)
104variableDeclaration.Type, 105lockTypeExpression.WithTriviaFrom(variableDeclaration.Type));
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (24)
Semantics\ArglistTests.cs (1)
963var type = stmt.Declaration.Type;
Semantics\FunctionPointerTests.cs (2)
3809FunctionPointerUtilities.VerifyFunctionPointerSemanticInfo(model, fieldDeclaration.Type, 3825FunctionPointerUtilities.VerifyFunctionPointerSemanticInfo(model, localDeclaration.Type,
Semantics\NullableReferenceTypesTests.cs (5)
35000var varDecl = tree.GetRoot().DescendantNodes().OfType<LocalDeclarationStatementSyntax>().Where(d => d.Declaration.Type.IsVar).Single(); 59065Assert.Equal("System.String?", model.GetTypeInfoAndVerifyIOperation(declaration.Type).Type.ToTestDisplayString()); 59066Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, model.GetTypeInfo(declaration.Type).Nullability.Annotation); 59067Assert.Equal("System.String?", model.GetTypeInfo(declaration.Type).ConvertedType.ToTestDisplayString()); 59068Assert.Equal(CodeAnalysis.NullableAnnotation.Annotated, model.GetTypeInfo(declaration.Type).ConvertedNullability.Annotation);
Semantics\RefFieldTests.cs (13)
12140var type = ((VariableDeclarationSyntax)decl.Parent).Type; 12208var type = ((VariableDeclarationSyntax)decl.Parent).Type; 12274var type = ((VariableDeclarationSyntax)decl.Parent).Type; 13520var type = ((VariableDeclarationSyntax)decl.Parent).Type; 13584var type = ((VariableDeclarationSyntax)decl.Parent).Type; 14428var type = ((VariableDeclarationSyntax)decls[0].Parent).Type; 14470var type = ((VariableDeclarationSyntax)decls[0].Parent).Type; 27673var type = ((VariableDeclarationSyntax)decl.Parent).Type; 27763var type = ((VariableDeclarationSyntax)decl.Parent).Type; 28034var type = ((VariableDeclarationSyntax)decl.Parent).Type; 28094var type = ((VariableDeclarationSyntax)decl.Parent).Type; 28316var type = ((VariableDeclarationSyntax)decls[0].Parent).Type; 28364var type = ((VariableDeclarationSyntax)decls[0].Parent).Type;
Semantics\UsingStatementTests.cs (3)
1347var typeInfo = model.GetSymbolInfo(usingStatement.Declaration.Type); 1386var typeInfo = model.GetSymbolInfo(usingStatement.Declaration.Type); 1883var type = model.GetSymbolInfo(usingStatements[index - 1].Declaration.Type);
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (24)
Compilation\GetSemanticInfoTests.cs (6)
4115var info0 = model.GetSymbolInfo(localDecl2.Type); 4119var info1 = model.GetSymbolInfo(localDecl1.Type); 4123var info2 = model.GetSymbolInfo(localDecl2.Type); 4170var info1 = model.GetSymbolInfo(localDecl1.Type); 4174var info2 = model.GetSymbolInfo(localDecl2.Type); 4438var qualifiedSyntax = (QualifiedNameSyntax)fieldSyntax.Declaration.Type;
Compilation\SemanticModelAPITests.cs (6)
644var program = staticProgramField.Declaration.Type; 675var type = field.Declaration.Type; 798var info = model.GetSymbolInfo((xDecl.Declaration.Type as QualifiedNameSyntax).Right); 1744var typeSyntax = (IdentifierNameSyntax)fieldDecl.Declaration.Type; 1793var typeInfo = speculativeModel.GetTypeInfo(localDecl.Declaration.Type); 2399var typeInfo = speculativeModel.GetTypeInfo(localDecl.Declaration.Type);
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (5)
2427var type = localDecl.Declaration.Type; 2459var type = localDecl.Declaration.Type; 2496var type = (QualifiedNameSyntax)localDecl.Declaration.Type; 2533var type = (QualifiedNameSyntax)localDecl.Declaration.Type; 3238var info = model.GetSemanticInfoSummary(localDecl.Declaration.Type);
SymbolDisplay\SymbolDisplayTests.cs (2)
8515var type = semanticModel.GetTypeInfo(declaration.Declaration.Type).Type; 8566var type = semanticModel.GetTypeInfo(declaration.Declaration.Type).Type;
Symbols\FunctionPointerTypeSymbolTests.cs (1)
1701FunctionPointerUtilities.VerifyFunctionPointerSemanticInfo(model, varDecl.Type,
Symbols\Source\NullablePublicAPITests.cs (4)
1629var type = model.GetTypeInfo(varDecl.Type); 1672var type = model.GetTypeInfo(varDecl.Type); 1715var type = model.GetTypeInfo(varDecl.Type); 1952var typeInfo = model.GetTypeInfoAndVerifyIOperation(((VariableDeclarationSyntax)variable.Parent).Type);
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (118)
Generated\Syntax.Test.xml.Generated.cs (2)
12429Assert.NotNull(node.Type); 12431var newNode = node.WithType(node.Type).WithVariables(node.Variables);
Parsing\DeclarationParsingTests.cs (20)
3626Assert.NotNull(fs.Declaration.Type); 3627Assert.Equal("b", fs.Declaration.Type.ToString()); 3686Assert.NotNull(fs.Declaration.Type); 3687Assert.Equal(typeText, fs.Declaration.Type.ToString()); 3727Assert.NotNull(fs.Declaration.Type); 3728Assert.Equal("b", fs.Declaration.Type.ToString()); 3782Assert.NotNull(fs.Declaration.Type); 3783Assert.Equal("b", fs.Declaration.Type.ToString()); 3837Assert.NotNull(fs.Declaration.Type); 3838Assert.Equal("b", fs.Declaration.Type.ToString()); 3881Assert.NotNull(fs.Declaration.Type); 3882Assert.Equal("b", fs.Declaration.Type.ToString()); 3925Assert.NotNull(fs.Declaration.Type); 3926Assert.Equal("b", fs.Declaration.Type.ToString()); 3970Assert.NotNull(fs.Declaration.Type); 3971Assert.Equal("b", fs.Declaration.Type.ToString()); 4024Assert.NotNull(fs.Declaration.Type); 4025Assert.Equal("b", fs.Declaration.Type.ToString()); 4088Assert.NotNull(fs.Declaration.Type); 4089Assert.Equal("b", fs.Declaration.Type.ToString());
Parsing\DeconstructionTests.cs (2)
1883Assert.Equal("(T, T)[]", declaration.Type.ToString()); 2049var nullable = (NullableTypeSyntax)declaration.Type;
Parsing\StatementParsingTests.cs (94)
194Assert.NotNull(ds.Declaration.Type); 195Assert.Equal("T", ds.Declaration.Type.ToString()); 222Assert.NotNull(ds.Declaration.Type); 223Assert.Equal("var", ds.Declaration.Type.ToString()); 224Assert.Equal(SyntaxKind.IdentifierName, ds.Declaration.Type.Kind()); 225Assert.Equal(SyntaxKind.IdentifierToken, ((IdentifierNameSyntax)ds.Declaration.Type).Identifier.Kind()); 252Assert.NotNull(ds.Declaration.Type); 253Assert.Equal("(int, int)", ds.Declaration.Type.ToString()); 254Assert.Equal(SyntaxKind.TupleType, ds.Declaration.Type.Kind()); 256var tt = (TupleTypeSyntax)ds.Declaration.Type; 286Assert.NotNull(ds.Declaration.Type); 287Assert.Equal("(T x, (U k, V l, W m) y)", ds.Declaration.Type.ToString()); 288Assert.Equal(SyntaxKind.TupleType, ds.Declaration.Type.Kind()); 290var tt = (TupleTypeSyntax)ds.Declaration.Type; 327Assert.NotNull(ds.Declaration.Type); 328Assert.Equal("dynamic", ds.Declaration.Type.ToString()); 329Assert.Equal(SyntaxKind.IdentifierName, ds.Declaration.Type.Kind()); 330Assert.Equal(SyntaxKind.IdentifierToken, ((IdentifierNameSyntax)ds.Declaration.Type).Identifier.Kind()); 355Assert.NotNull(ds.Declaration.Type); 356Assert.Equal("T<a>", ds.Declaration.Type.ToString()); 381Assert.NotNull(ds.Declaration.Type); 382Assert.Equal("T.X.Y", ds.Declaration.Type.ToString()); 407Assert.NotNull(ds.Declaration.Type); 408Assert.Equal("T<t>.X<x>.Y<y>", ds.Declaration.Type.ToString()); 433Assert.NotNull(ds.Declaration.Type); 434Assert.Equal("T[][,][,,]", ds.Declaration.Type.ToString()); 459Assert.NotNull(ds.Declaration.Type); 460Assert.Equal("T*", ds.Declaration.Type.ToString()); 485Assert.NotNull(ds.Declaration.Type); 486Assert.Equal("T?", ds.Declaration.Type.ToString()); 511Assert.NotNull(ds.Declaration.Type); 512Assert.Equal("T", ds.Declaration.Type.ToString()); 546Assert.NotNull(ds.Declaration.Type); 547Assert.Equal("T", ds.Declaration.Type.ToString()); 576Assert.NotNull(ds.Declaration.Type); 577Assert.Equal("T", ds.Declaration.Type.ToString()); 621Assert.NotNull(ds.Declaration.Type); 622Assert.Equal("T", ds.Declaration.Type.ToString()); 653Assert.NotNull(ds.Declaration.Type); 654Assert.Equal("T", ds.Declaration.Type.ToString()); 685Assert.NotNull(ds.Declaration.Type); 686Assert.Equal("T", ds.Declaration.Type.ToString()); 717Assert.NotNull(ds.Declaration.Type); 718Assert.Equal("T", ds.Declaration.Type.ToString()); 749Assert.NotNull(ds.Declaration.Type); 750Assert.Equal("T", ds.Declaration.Type.ToString()); 779Assert.NotNull(ds.Declaration.Type); 780Assert.Equal("ref T", ds.Declaration.Type.ToString()); 805Assert.NotNull(ds.Declaration.Type); 806Assert.Equal("ref T", ds.Declaration.Type.ToString()); 836Assert.NotNull(ds.Declaration.Type); 837Assert.Equal("ref T", ds.Declaration.Type.ToString()); 882Assert.NotNull(fs.Declaration.Type); 883Assert.Equal("T", fs.Declaration.Type.ToString()); 909Assert.NotNull(fs.Declaration.Type); 910Assert.Equal("var", fs.Declaration.Type.ToString()); 911Assert.True(fs.Declaration.Type.IsVar); 912Assert.Equal(SyntaxKind.IdentifierName, fs.Declaration.Type.Kind()); 913Assert.Equal(SyntaxKind.IdentifierToken, ((IdentifierNameSyntax)fs.Declaration.Type).Identifier.Kind()); 939Assert.NotNull(fs.Declaration.Type); 940Assert.Equal("T", fs.Declaration.Type.ToString()); 1558Assert.NotNull(fs.Declaration.Type); 1559Assert.Equal("T", fs.Declaration.Type.ToString()); 1595Assert.NotNull(fs.Declaration.Type); 1596Assert.Equal("var", fs.Declaration.Type.ToString()); 1597Assert.Equal(SyntaxKind.IdentifierName, fs.Declaration.Type.Kind()); 1598Assert.Equal(SyntaxKind.IdentifierToken, ((IdentifierNameSyntax)fs.Declaration.Type).Identifier.Kind()); 1634Assert.NotNull(fs.Declaration.Type); 1635Assert.Equal("T", fs.Declaration.Type.ToString()); 1893Assert.NotNull(fs.Declaration.Type); 1894Assert.Equal("T", fs.Declaration.Type.ToString()); 2372Assert.NotNull(us.Declaration.Type); 2373Assert.Equal("T", us.Declaration.Type.ToString()); 2405Assert.NotNull(us.Declaration.Type); 2406Assert.Equal("T", us.Declaration.Type.ToString()); 2465Assert.NotNull(us.Declaration.Type); 2466Assert.Equal("var", us.Declaration.Type.ToString()); 2467Assert.Equal(SyntaxKind.IdentifierName, us.Declaration.Type.Kind()); 2468Assert.Equal(SyntaxKind.IdentifierToken, ((IdentifierNameSyntax)us.Declaration.Type).Identifier.Kind()); 2500Assert.NotNull(us.Declaration.Type); 2501Assert.Equal("var", us.Declaration.Type.ToString()); 2502Assert.Equal(SyntaxKind.IdentifierName, us.Declaration.Type.Kind()); 2503Assert.Equal(SyntaxKind.IdentifierToken, ((IdentifierNameSyntax)us.Declaration.Type).Identifier.Kind()); 2634Assert.NotNull(us.Declaration.Type); 2635Assert.Equal("var", us.Declaration.Type.ToString()); 2636Assert.Equal(SyntaxKind.IdentifierName, us.Declaration.Type.Kind()); 2637Assert.Equal(SyntaxKind.IdentifierToken, ((IdentifierNameSyntax)us.Declaration.Type).Identifier.Kind()); 2805Assert.NotNull(us.Declaration.Type); 2806Assert.Equal("T", us.Declaration.Type.ToString()); 2848Assert.NotNull(us.Declaration.Type); 2849Assert.Equal("T", us.Declaration.Type.ToString()); 3349Assert.Equal(keywordText, decl.Declaration.Type.ToString()); 3350Assert.IsType<IdentifierNameSyntax>(decl.Declaration.Type); 3351var name = (IdentifierNameSyntax)decl.Declaration.Type;
Microsoft.CodeAnalysis.CSharp.Test.Utilities (1)
CompilationTestUtils.cs (1)
370=> (expression.Parent is VariableDeclarationSyntax decl && decl.Type == expression) ||
Microsoft.CodeAnalysis.CSharp.Workspaces (31)
Classification\SyntaxClassification\NameSyntaxClassifier.cs (1)
279name.CheckParent<VariableDeclarationSyntax>(v => v.Type == name) ||
CodeGeneration\CSharpSyntaxGenerator.cs (6)
2126return ((FieldDeclarationSyntax)declaration).Declaration.Type; 2132return ((EventFieldDeclarationSyntax)declaration).Declaration.Type; 2138return ((LocalDeclarationStatementSyntax)declaration).Declaration.Type; 2140return ((VariableDeclarationSyntax)declaration).Type; 2981return SyntaxFactory.AreEquivalent(vd1.Type, vd2.Type) && AreSimilarExceptForSubDeclarations(vd1.Parent, vd2.Parent);
Recommendations\CSharpRecommendationServiceRunner.cs (1)
356!contextNode.IsFoundUnder<LocalDeclarationStatementSyntax>(d => d.Declaration.Type) &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\DefaultExpressionSyntaxExtensions.cs (1)
72return declaration.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ExpressionSyntaxExtensions.cs (2)
337if (refParent.Parent is EqualsValueClauseSyntax { Parent: VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Type: { } variableDeclarationType } } }) 988if (equalsValue.Parent is VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Type.IsVar: true } })
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\MemberDeclarationSyntaxExtensions.cs (2)
169return ((EventFieldDeclarationSyntax)member).Declaration.Type; 171return ((FieldDeclarationSyntax)member).Declaration.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ParenthesizedExpressionSyntaxExtensions.cs (2)
75if (semanticModel.GetTypeInfo(varDecl.Type, cancellationToken).Type.IsSpanOrReadOnlySpan()) 76return !varDecl.Type.IsVar;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\VariableDeclaratorExtensions.cs (1)
17return variableDeclaration.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (1)
1331=> ((VariableDeclarationSyntax)((VariableDeclaratorSyntax)node).Parent!).Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpTypeStyleHelper.cs (1)
88? variableDeclaration.Type
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpTypeStyleHelper.State.cs (2)
78var declaredTypeSymbol = semanticModel.GetTypeInfo(variableDeclaration.Type.StripRefIfNeeded(), cancellationToken).Type; 142VariableDeclarationSyntax varDecl => varDecl.Type,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseExplicitTypeHelper.cs (1)
43if (!variableDeclaration.Type.StripRefIfNeeded().IsVar)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (2)
50var type = variableDeclaration.Type.StripRefIfNeeded(); 129if (!variableDeclaration.Type.IsKind(SyntaxKind.PointerType) &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (2)
890.WithLeadingTrivia(variableDeclarationSyntax.Type.GetLeadingTrivia()) 891.WithTrailingTrivia(variableDeclarationSyntax.Type.GetTrailingTrivia());
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ExpressionSyntaxExtensions.cs (2)
173name.IsFoundUnder<LocalDeclarationStatementSyntax>(d => d.Declaration.Type) || 174name.IsFoundUnder<FieldDeclarationSyntax>(d => d.Declaration.Type))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpMoveDeclarationNearReferenceService.cs (1)
57var type = declarationStatement.Declaration.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpReplaceDiscardDeclarationsWithAssignmentsService.cs (3)
196var leadingTrivia = _localDeclarationStatement.Declaration.Type.GetLeadingTrivia() 197.Concat(_localDeclarationStatement.Declaration.Type.GetTrailingTrivia()); 233VariableDeclaration(_localDeclarationStatement.Declaration.Type, _currentNonDiscardVariables))
Microsoft.Interop.LibraryImportGenerator (1)
Analyzers\ConvertToLibraryImportFixer.cs (1)
367declaration.Declaration.Type,
Microsoft.VisualStudio.LanguageServices.CSharp (4)
CodeModel\CSharpCodeModelService.CodeModelEventCollector.cs (2)
393if (!CompareTypes(oldField.Declaration.Type, newField.Declaration.Type))
CodeModel\MethodXml\MethodXmlBuilder.cs (1)
111if (!TryGenerateType(localDeclarationStatement.Declaration.Type))
LanguageService\CSharpHelpContextService.cs (1)
525token.Parent?.Parent is VariableDeclarationSyntax declaration && token.Parent == declaration.Type)
Roslyn.Diagnostics.CSharp.Analyzers (23)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\DefaultExpressionSyntaxExtensions.cs (1)
72return declaration.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ExpressionSyntaxExtensions.cs (2)
337if (refParent.Parent is EqualsValueClauseSyntax { Parent: VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Type: { } variableDeclarationType } } }) 988if (equalsValue.Parent is VariableDeclaratorSyntax { Parent: VariableDeclarationSyntax { Type.IsVar: true } })
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\MemberDeclarationSyntaxExtensions.cs (2)
169return ((EventFieldDeclarationSyntax)member).Declaration.Type; 171return ((FieldDeclarationSyntax)member).Declaration.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ParenthesizedExpressionSyntaxExtensions.cs (2)
75if (semanticModel.GetTypeInfo(varDecl.Type, cancellationToken).Type.IsSpanOrReadOnlySpan()) 76return !varDecl.Type.IsVar;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\VariableDeclaratorExtensions.cs (1)
17return variableDeclaration.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (1)
1331=> ((VariableDeclarationSyntax)((VariableDeclaratorSyntax)node).Parent!).Type;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpTypeStyleHelper.cs (1)
88? variableDeclaration.Type
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpTypeStyleHelper.State.cs (2)
78var declaredTypeSymbol = semanticModel.GetTypeInfo(variableDeclaration.Type.StripRefIfNeeded(), cancellationToken).Type; 142VariableDeclarationSyntax varDecl => varDecl.Type,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseExplicitTypeHelper.cs (1)
43if (!variableDeclaration.Type.StripRefIfNeeded().IsVar)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (2)
50var type = variableDeclaration.Type.StripRefIfNeeded(); 129if (!variableDeclaration.Type.IsKind(SyntaxKind.PointerType) &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (2)
890.WithLeadingTrivia(variableDeclarationSyntax.Type.GetLeadingTrivia()) 891.WithTrailingTrivia(variableDeclarationSyntax.Type.GetTrailingTrivia());
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ExpressionSyntaxExtensions.cs (2)
173name.IsFoundUnder<LocalDeclarationStatementSyntax>(d => d.Declaration.Type) || 174name.IsFoundUnder<FieldDeclarationSyntax>(d => d.Declaration.Type))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpMoveDeclarationNearReferenceService.cs (1)
57var type = declarationStatement.Declaration.Type;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpReplaceDiscardDeclarationsWithAssignmentsService.cs (3)
196var leadingTrivia = _localDeclarationStatement.Declaration.Type.GetLeadingTrivia() 197.Concat(_localDeclarationStatement.Declaration.Type.GetTrailingTrivia()); 233VariableDeclaration(_localDeclarationStatement.Declaration.Type, _currentNonDiscardVariables))