2 implementations of IFieldSymbol
Microsoft.CodeAnalysis.CSharp (1)
Symbols\PublicModel\FieldSymbol.cs (1)
13internal sealed class FieldSymbol : Symbol, IFieldSymbol
Microsoft.CodeAnalysis.VisualBasic (1)
Symbols\FieldSymbol.vb (1)
21Implements IFieldSymbol, IFieldSymbolInternal
1271 references to IFieldSymbol
ILLink.RoslynAnalyzer (31)
DataFlow\DynamicallyAccessedMembersBinder.cs (6)
62 foreach (var f in typeDefinition.ApplyIncludeInherited (t => t.GetFieldsOnTypeHierarchy (filter: null, bindingFlags: BindingFlags.NonPublic | declaredOnlyFlags), withInherited)) 67 foreach (var f in typeDefinition.GetFieldsOnTypeHierarchy (filter: null, bindingFlags: BindingFlags.Public | declaredOnlyFlags)) 189 public static IEnumerable<IFieldSymbol> GetFieldsOnTypeHierarchy (this ITypeSymbol thisType, Func<IFieldSymbol, bool>? filter, BindingFlags? bindingFlags = BindingFlags.Default) 194 foreach (var field in type.GetMembers ().OfType<IFieldSymbol> ()) {
DataFlow\LocalDataFlowVisitor.cs (4)
103 Debug.Assert (OwningSymbol is IMethodSymbol or IFieldSymbol or IPropertySymbol, 131 public abstract TValue GetFieldTargetValue (IFieldSymbol field, IFieldReferenceOperation fieldReferenceOperation, in TContext context); 204 Debug.Assert (local.ContainingSymbol is IMethodSymbol or IFieldSymbol, // backing field for property initializers 715 Debug.Assert (operation.Symbol.ContainingSymbol is IMethodSymbol or IFieldSymbol);
DataFlow\MethodBodyValue.cs (1)
23 Debug.Assert (owningSymbol is (IMethodSymbol or IFieldSymbol or IPropertySymbol));
DynamicallyAccessedMembersAnalyzer.cs (1)
153 if (member is IFieldSymbol field && field.GetDynamicallyAccessedMemberTypes () != DynamicallyAccessedMemberTypes.None && !field.Type.IsTypeInterestingForDataflow (isByRef: field.RefKind is not RefKind.None))
ISymbolExtensions.cs (1)
139 case IFieldSymbol fieldSymbol:
RequiresISymbolExtensions.cs (1)
65 if (member is IFieldSymbol field && !field.IsStatic) {
TrimAnalysis\FieldValue.cs (2)
14 public FieldValue (IFieldSymbol fieldSymbol) 21 public readonly IFieldSymbol FieldSymbol;
TrimAnalysis\FlowAnnotations.cs (3)
41 IFieldSymbol field => ShouldWarnWhenAccessedForReflection (field), 105 static bool ShouldWarnWhenAccessedForReflection (IFieldSymbol field) 110 internal static DynamicallyAccessedMemberTypes GetFieldAnnotation (IFieldSymbol field)
TrimAnalysis\GenericArgumentDataFlow.cs (2)
30 public static void ProcessGenericArgumentDataFlow (Location location, IFieldSymbol field, Action<Diagnostic> reportDiagnostic) 93 public static bool RequiresGenericArgumentDataFlow (IFieldSymbol field)
TrimAnalysis\ReflectionAccessAnalyzer.cs (4)
35 case IFieldSymbol field: 64 foreach (var field in typeSymbol.GetFieldsOnTypeHierarchy (f => f.Name == name, bindingFlags)) 110 Debug.Assert (member is IMethodSymbol or IFieldSymbol); 184 void GetDiagnosticsForField (Location location, IFieldSymbol fieldSymbol)
TrimAnalysis\TrimAnalysisFieldAccessPattern.cs (2)
15 public IFieldSymbol Field { get; init; } 21 IFieldSymbol field,
TrimAnalysis\TrimAnalysisGenericInstantiationPattern.cs (1)
61 case IFieldSymbol field:
TrimAnalysis\TrimAnalysisVisitor.cs (3)
157 var field = fieldRef.Field; 218 public override MultiValue GetFieldTargetValue (IFieldSymbol field, IFieldReferenceOperation fieldReferenceOperation, in FeatureContext featureContext) 409 private void ProcessGenericArgumentDataFlow (IFieldSymbol field, IOperation operation, in FeatureContext featureContext)
Microsoft.Analyzers.Local (2)
ApiLifecycle\AssemblyAnalysis.cs (1)
247else if (member is IFieldSymbol fieldSym)
Utilities\SymbolExtensions.cs (1)
166if (symbol is IFieldSymbol fieldSymbol)
Microsoft.AspNetCore.App.Analyzers (1)
RouteEmbeddedLanguage\Infrastructure\RouteStringSyntaxDetector.cs (1)
303return symbol is IFieldSymbol or IPropertySymbol &&
Microsoft.AspNetCore.Components.Analyzers (2)
ComponentParameterAnalyzer.cs (1)
146.OfType<IFieldSymbol>()
InternalUsageAnalyzer.cs (1)
92case IFieldSymbol field:
Microsoft.AspNetCore.Components.SdkAnalyzers (1)
InternalUsageAnalyzer.cs (1)
92case IFieldSymbol field:
Microsoft.AspNetCore.Mvc.Api.Analyzers (1)
AddResponseTypeAttributeCodeFixAction.cs (1)
155if (member is IFieldSymbol field &&
Microsoft.CodeAnalysis (26)
DiagnosticAnalyzer\AnalyzerExecutor.cs (1)
1137Debug.Assert(((IFieldSymbol)symbol).AssociatedSymbol == null);
DocumentationCommentId.cs (2)
357public override void VisitField(IFieldSymbol symbol) 429public override bool VisitField(IFieldSymbol symbol)
Generated\Operations.Generated.cs (6)
936IFieldSymbol Field { get; } 2352ImmutableArray<IFieldSymbol> InitializedFields { get; } 5345internal FieldReferenceOperation(IFieldSymbol field, bool isDeclaration, IOperation? instance, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) 5353public IFieldSymbol Field { get; } 7510internal FieldInitializerOperation(ImmutableArray<IFieldSymbol> initializedFields, ImmutableArray<ILocalSymbol> locals, IOperation value, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit) 7515public ImmutableArray<IFieldSymbol> InitializedFields { get; }
Operations\ControlFlowGraphBuilder.cs (1)
7218foreach (IFieldSymbol fieldSymbol in operation.InitializedFields)
SymbolDisplay\AbstractSymbolDisplayVisitor.cs (5)
281((IFieldSymbol)usedFieldsAndValues[i].IdentityOpt!).Accept(this.NotFirstVisitor); 301((IFieldSymbol)zeroField.IdentityOpt).Accept(this.NotFirstVisitor); 321var field = (IFieldSymbol)member; 347((IFieldSymbol)match.IdentityOpt).Accept(this.NotFirstVisitor);
SymbolDisplay\AbstractSymbolDisplayVisitor_Minimal.cs (2)
105var fieldSymbol = symbol as IFieldSymbol;
Symbols\IFieldSymbol.cs (2)
106new IFieldSymbol OriginalDefinition { get; } 117IFieldSymbol? CorrespondingTupleField { get; }
Symbols\INamedTypeSymbol.cs (1)
186ImmutableArray<IFieldSymbol> TupleElements { get; }
Symbols\ISymbolExtensions.cs (3)
67internal static bool IsDefaultTupleElement(this IFieldSymbol field) 75internal static bool IsTupleElement(this IFieldSymbol field) 88internal static string? ProvidedTupleElementNameOrNull(this IFieldSymbol field)
Symbols\SymbolVisitor.cs (1)
48public virtual void VisitField(IFieldSymbol symbol)
Symbols\SymbolVisitor`1.cs (1)
51public virtual TResult? VisitField(IFieldSymbol symbol)
Symbols\SymbolVisitor`2.cs (1)
56public virtual TResult VisitField(IFieldSymbol symbol, TArgument argument)
Microsoft.CodeAnalysis.CodeStyle (86)
src\Analyzers\Core\Analyzers\MakeFieldReadonly\AbstractMakeFieldReadonlyDiagnosticAnalyzer.cs (13)
42var fieldStateMap = new ConcurrentDictionary<IFieldSymbol, (bool isCandidate, bool written)>(); 88var field = (IFieldSymbol)symbolContext.Symbol; 117if (member is IFieldSymbol field && fieldStateMap.TryRemove(field.OriginalDefinition, out var value)) 141if (member is IFieldSymbol field && 157bool IsCandidateField(IFieldSymbol symbol) 188static bool IsDataContractSerializable(IFieldSymbol symbol, INamedTypeSymbol? dataContractAttribute, INamedTypeSymbol? dataMemberAttribute) 198void UpdateFieldStateOnWrite(IFieldSymbol field) 207(bool isCandidate, bool written) TryGetOrInitializeFieldState(IFieldSymbol fieldSymbol, AnalyzerOptions options, CancellationToken cancellationToken) 221IFieldSymbol field, 240private static Location GetDiagnosticLocation(IFieldSymbol field) 263var field = fieldReference.Field; 299private static CodeStyleOption2<bool> GetCodeStyleOption(IFieldSymbol field, AnalyzerOptions options, out Location diagnosticLocation)
src\Analyzers\Core\Analyzers\PopulateSwitch\PopulateSwitchStatementHelpers.cs (1)
158if (member is not IFieldSymbol fieldSymbol || fieldSymbol.Type.SpecialType != SpecialType.None)
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (5)
289foreach (var field in initializer.InitializedFields) 483if (isInlineArray && member is IFieldSymbol { IsStatic: false }) 705case IPropertySymbol or IFieldSymbol: 733/// Backing fields have a non-null <see cref="IFieldSymbol.AssociatedSymbol"/>. 852return ((IFieldSymbol)memberSymbol).AssociatedSymbol == null;
src\Analyzers\Core\Analyzers\UseAutoProperty\AbstractUseAutoPropertyAnalyzer.cs (20)
46private static readonly ObjectPool<ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>>> s_fieldToUsageLocationPool = new(() => []); 63protected static void AddFieldUsage(ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> fieldWrites, IFieldSymbol field, SyntaxNode location) 66private static void ClearAndFree(ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> multiMap) 100SemanticModel semanticModel, IMethodSymbol accessor, HashSet<string> fieldNames, HashSet<IFieldSymbol> result, CancellationToken cancellationToken); 103HashSet<string> fieldNames, ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> ineligibleFieldUsageIfOutsideProperty, SemanticModel semanticModel, SyntaxNode codeBlock, CancellationToken cancellationToken); 131if (member is IFieldSymbol 229ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> fieldReads, 230ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> fieldWrites, 243if (semanticModel.GetSymbolInfo(identifierName, cancellationToken).Symbol is not IFieldSymbol field) 275using var _ = PooledHashSet<IFieldSymbol>.GetInstance(out var set); 291using var _ = PooledHashSet<IFieldSymbol>.GetInstance(out var set); 297private IFieldSymbol? CheckFieldAccessExpression( 316IFieldSymbol field, 483var getterField = getterFields.TrivialField ?? getterFields.NonTrivialFields.Single(); 499protected IFieldSymbol? TryGetDirectlyAccessedFieldSymbol( 539ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> ineligibleFieldUsageIfOutsideProperty, 540ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> fieldReads, 541ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> fieldWrites, 544using var _1 = PooledHashSet<IFieldSymbol>.GetInstance(out var reportedFields);
src\Analyzers\Core\Analyzers\UseAutoProperty\AccessedFields.cs (5)
16IFieldSymbol? TrivialField, 17ImmutableArray<IFieldSymbol> NonTrivialFields) 21public AccessedFields(IFieldSymbol? trivialField) : this(trivialField, []) 28public AccessedFields Where<TArg>(Func<IFieldSymbol, TArg, bool> predicate, TArg arg) 32public bool Contains(IFieldSymbol field)
src\Analyzers\Core\Analyzers\UseAutoProperty\AnalysisResult.cs (1)
33IFieldSymbol Field,
src\Analyzers\Core\Analyzers\UseExplicitTupleName\UseExplicitTupleNameDiagnosticAnalyzer.cs (6)
49var field = fieldReferenceOperation.Field; 54var namedField = GetNamedField(field.ContainingType, field, context.CancellationToken); 76private static IFieldSymbol? GetNamedField( 77INamedTypeSymbol containingType, IFieldSymbol unnamedField, CancellationToken cancellationToken) 85var fieldSymbol = (IFieldSymbol)member;
src\Workspaces\Core\Portable\Editing\DeclarationModifiers.cs (3)
68IFieldSymbol or 73var field = symbol as IFieldSymbol;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\INamedTypeSymbolExtensions.cs (2)
485var fieldSymbol = (IFieldSymbol)symbol;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\IPropertySymbolExtensions.cs (2)
11public static IFieldSymbol? GetBackingFieldIfAny(this IPropertySymbol property) 13.OfType<IFieldSymbol>()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ISymbolExtensions.cs (5)
309=> symbol is IFieldSymbol { ContainingType.IsTupleType: true }; 317IFieldSymbol fieldSymbol => !fieldSymbol.IsReadOnly && !fieldSymbol.IsConst, 323=> symbol is IFieldSymbol { IsRequired: true } or IPropertySymbol { IsRequired: true }; 328IFieldSymbol fieldSymbol => fieldSymbol.Type, 616IFieldSymbol fieldSymbol => fieldSymbol.Type,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ISymbolExtensions.RequiresUnsafeModifierVisitor.cs (1)
44public override bool VisitField(IFieldSymbol symbol)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ITypeSymbolExtensions.cs (1)
695if (member is not IFieldSymbol fieldSymbol)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SymbolSpecification.cs (2)
510if (kind == SymbolKind.Field && ((IFieldSymbol)symbol).IsReadOnly) 518if ((kind == SymbolKind.Field && ((IFieldSymbol)symbol).IsConst) ||
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
66/// <item>Two <see cref="IFieldSymbol"/>s are the "same" if they have
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.FieldSymbolKey.cs (4)
9private sealed class FieldSymbolKey : AbstractSymbolKey<IFieldSymbol> 13public sealed override void Create(IFieldSymbol symbol, SymbolKeyWriter visitor) 20SymbolKeyReader reader, IFieldSymbol? contextualSymbol, out string? failureReason) 31using var result = GetMembersOfNamedType<IFieldSymbol>(containingTypeResolution, metadataName);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
350public override void VisitField(IFieldSymbol fieldSymbol)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.TupleTypeSymbolKey.cs (2)
29foreach (var element in symbol.TupleElements) 43foreach (var element in symbol.TupleElements)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (1)
23.OfType<IFieldSymbol>()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\SymbolEquivalenceComparer.EquivalenceVisitor.cs (8)
120SymbolKind.Field => FieldsAreEquivalent((IFieldSymbol)x, (IFieldSymbol)y, equivalentTypesWithDifferingAssemblies), 151private bool FieldsAreEquivalent(IFieldSymbol x, IFieldSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies) 433var xElement = xElements[i]; 434var yElement = yElements[i]; 450var xElement = xElements[i]; 451var yElement = yElements[i];
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\SymbolEquivalenceComparer.GetHashCodeVisitor.cs (2)
62SymbolKind.Field => CombineHashCodes((IFieldSymbol)x, currentHash), 89private int CombineHashCodes(IFieldSymbol x, int currentHash)
Microsoft.CodeAnalysis.CodeStyle.Fixes (58)
src\Analyzers\Core\CodeFixes\GenerateConstructor\AbstractGenerateConstructorService.State.cs (1)
545if (symbol is IFieldSymbol field)
src\Analyzers\Core\CodeFixes\GenerateVariable\AbstractGenerateVariableService.CodeAction.cs (1)
92var fieldSymbol = CodeGenerationSymbolFactory.CreateFieldSymbol(
src\Analyzers\Core\CodeFixes\GenerateVariable\AbstractGenerateVariableService.State.cs (1)
414=> symbol is IFieldSymbol field && field.IsReadOnly;
src\Analyzers\Core\CodeFixes\ImplementInterface\ImplementHelpers.cs (4)
27.OfType<IFieldSymbol>() 43ImmutableArray<IFieldSymbol> fields, 65bool IsAssignedToFieldOrProperty(ImmutableArray<IFieldSymbol> fields, ImmutableArray<IPropertySymbol> properties, IParameterSymbol parameter) 68bool IsAssignedToField(IFieldSymbol field, IParameterSymbol parameter)
src\Analyzers\Core\CodeFixes\ImplementInterface\ImplementInterfaceGenerator_DisposePattern.cs (3)
120IFieldSymbol disposedValueField) 138IFieldSymbol disposedValueField) 233private static async Task<IFieldSymbol> CreateDisposedValueFieldAsync(
src\Analyzers\Core\CodeFixes\MakeFieldReadonly\AbstractMakeFieldReadonlyCodeFixProvider.cs (2)
80var symbol = (IFieldSymbol?)model.GetDeclaredSymbol(declarator, cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (9)
51public TDeclarationNode AddField<TDeclarationNode>(TDeclarationNode destination, IFieldSymbol field, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode 80public SyntaxNode CreateFieldDeclaration(IFieldSymbol field, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken) 125protected abstract TDeclarationNode AddField<TDeclarationNode>(TDeclarationNode destination, IFieldSymbol field, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode; 145public abstract SyntaxNode CreateFieldDeclaration(IFieldSymbol field, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken); 347IFieldSymbol field => CreateFieldDeclaration(field, codeGenerationDestination, info, cancellationToken), 365IFieldSymbol field => AddField(currentDestination, field, info, availableIndices, cancellationToken), 376var field = members.OfType<IFieldSymbol>().FirstOrDefault(); 402public Task<Document> AddFieldAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IFieldSymbol field, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractFlagsEnumGenerator.cs (17)
13internal abstract class AbstractFlagsEnumGenerator : IComparer<(IFieldSymbol field, ulong value)> 66var allFieldsAndValues = new List<(IFieldSymbol field, ulong value)>(); 69var usedFieldsAndValues = new List<(IFieldSymbol field, ulong value)>(); 77List<(IFieldSymbol field, ulong value)> allFieldsAndValues, 78List<(IFieldSymbol field, ulong value)> usedFieldsAndValues) 128var zeroField = GetZeroField(allFieldsAndValues); 141SyntaxGenerator generator, IFieldSymbol field, INamedTypeSymbol enumType, SpecialType underlyingSpecialType) 156private static IFieldSymbol? GetZeroField(List<(IFieldSymbol field, ulong value)> allFieldsAndValues) 172List<(IFieldSymbol field, ulong value)> allFieldsAndValues) 176foreach (var field in enumType.GetMembers().OfType<IFieldSymbol>()) 195foreach (var field in enumType.GetMembers().OfType<IFieldSymbol>()) 211int IComparer<(IFieldSymbol field, ulong value)>.Compare((IFieldSymbol field, ulong value) x, (IFieldSymbol field, ulong value) y)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (1)
158.OfType<IFieldSymbol>()
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (3)
107public static IFieldSymbol CreateFieldSymbol( 594internal static IFieldSymbol CreateFieldSymbol( 595IFieldSymbol field,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerator.cs (1)
37public static Task<Document> AddFieldDeclarationAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IFieldSymbol field, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\ICodeGenerationService.cs (3)
28SyntaxNode CreateFieldDeclaration(IFieldSymbol field, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken); 59TDeclarationNode AddField<TDeclarationNode>(TDeclarationNode destination, IFieldSymbol field, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode; 139Task<Document> AddFieldAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IFieldSymbol field, CancellationToken cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationAbstractNamedTypeSymbol.cs (1)
23public ImmutableArray<IFieldSymbol> TupleElements { get; protected set; }
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationFieldInfo.cs (6)
13private static readonly ConditionalWeakTable<IFieldSymbol, CodeGenerationFieldInfo> s_fieldToInfoMap = new(); 30IFieldSymbol field, 39private static CodeGenerationFieldInfo GetInfo(IFieldSymbol field) 48public static bool GetIsUnsafe(IFieldSymbol field) 54public static bool GetIsWithEvents(IFieldSymbol field) 60public static SyntaxNode GetInitializer(IFieldSymbol field)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationFieldSymbol.cs (3)
25object constantValue) : CodeGenerationSymbol(containingType?.ContainingAssembly, containingType, attributes, accessibility, modifiers, name), IFieldSymbol 39public new IFieldSymbol OriginalDefinition 47public IFieldSymbol CorrespondingTupleField => null;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions.cs (1)
90IFieldSymbol field => field.Type,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_CreateEqualsMethod.cs (1)
506.OfType<IFieldSymbol>()
Microsoft.CodeAnalysis.CSharp (45)
Compilation\CSharpSemanticModel.cs (2)
597case IFieldSymbol field: 2995public abstract IFieldSymbol GetDeclaredSymbol(EnumMemberDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken));
Compilation\MemberSemanticModel.cs (1)
615public override IFieldSymbol GetDeclaredSymbol(EnumMemberDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
Compilation\QueryClauseInfo.cs (1)
43/// <see cref="IFieldSymbol"/> or <see cref="IPropertySymbol"/> that return a delegate.
Compilation\SpeculativeSemanticModelWithMemberModel.cs (1)
275public override IFieldSymbol GetDeclaredSymbol(EnumMemberDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
Compilation\SyntaxTreeSemanticModel.cs (1)
1492public override IFieldSymbol GetDeclaredSymbol(EnumMemberDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
CSharpExtensions.cs (1)
1400public static IFieldSymbol? GetDeclaredSymbol(this SemanticModel? semanticModel, EnumMemberDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
Operations\CSharpOperationFactory.cs (3)
574IFieldSymbol field = boundFieldAccess.FieldSymbol.GetPublicSymbol(); 1726ImmutableArray<IFieldSymbol> initializedFields = ImmutableArray.Create<IFieldSymbol>(boundFieldEqualsValue.Field.GetPublicSymbol());
SymbolDisplay\SymbolDisplayVisitor.Members.cs (5)
22private void VisitFieldType(IFieldSymbol symbol) 27public override void VisitField(IFieldSymbol symbol) 894private void AddFieldModifiersIfNeeded(IFieldSymbol symbol) 932var isConst = symbol is IFieldSymbol { IsConst: true }; 933var isRequired = symbol is IFieldSymbol { IsRequired: true } or IPropertySymbol { IsRequired: true };
SymbolDisplay\SymbolDisplayVisitor.Types.cs (2)
547ImmutableArray<IFieldSymbol> elements = symbol.TupleElements; 552var element = elements[i];
Symbols\PublicModel\FieldSymbol.cs (19)
26ISymbol IFieldSymbol.AssociatedSymbol 34RefKind IFieldSymbol.RefKind => _underlying.RefKind; 36ImmutableArray<CustomModifier> IFieldSymbol.RefCustomModifiers => _underlying.RefCustomModifiers; 38ITypeSymbol IFieldSymbol.Type 51CodeAnalysis.NullableAnnotation IFieldSymbol.NullableAnnotation => _underlying.TypeWithAnnotations.ToPublicAnnotation(); 53ImmutableArray<CustomModifier> IFieldSymbol.CustomModifiers 58IFieldSymbol IFieldSymbol.OriginalDefinition 66IFieldSymbol IFieldSymbol.CorrespondingTupleField 74bool IFieldSymbol.IsExplicitlyNamedTupleElement 82bool IFieldSymbol.IsConst => _underlying.IsConst; 84bool IFieldSymbol.IsReadOnly => _underlying.IsReadOnly; 86bool IFieldSymbol.IsVolatile => _underlying.IsVolatile; 88bool IFieldSymbol.IsRequired => _underlying.IsRequired; 90bool IFieldSymbol.IsFixedSizeBuffer => _underlying.IsFixedSizeBuffer; 92int IFieldSymbol.FixedSize => _underlying.FixedSize; 94bool IFieldSymbol.HasConstantValue => _underlying.HasConstantValue; 96object IFieldSymbol.ConstantValue => _underlying.ConstantValue;
Symbols\PublicModel\NamedTypeSymbol.cs (1)
159ImmutableArray<IFieldSymbol> INamedTypeSymbol.TupleElements
Symbols\SymbolExtensions.cs (4)
623internal static IFieldSymbol? GetPublicSymbol(this FieldSymbol? symbol) 625return symbol.GetPublicSymbol<IFieldSymbol>(); 754internal static ImmutableArray<IFieldSymbol> GetPublicSymbols(this ImmutableArray<FieldSymbol> symbols) 756return GetPublicSymbols<IFieldSymbol>(StaticCast<Symbol>.From(symbols));
Symbols\TypedConstantExtensions.cs (4)
85var field = member as IFieldSymbol; 164var field = member as IFieldSymbol;
Microsoft.CodeAnalysis.CSharp.CodeStyle (21)
src\Analyzers\CSharp\Analyzers\MakeStructFieldsWritable\CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs (1)
80.OfType<IFieldSymbol>()
src\Analyzers\CSharp\Analyzers\MakeStructReadOnly\CSharpMakeStructReadOnlyDiagnosticAnalyzer.cs (1)
104if (member is IFieldSymbol field)
src\Analyzers\CSharp\Analyzers\UseAutoProperty\CSharpUseAutoPropertyAnalyzer.cs (4)
67ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> ineligibleFieldUsageIfOutsideProperty, 133if (symbolInfo.GetAnySymbol() is not IFieldSymbol { ContainingType.TypeKind: TypeKind.Struct }) 162if (symbol is IFieldSymbol field) 260HashSet<IFieldSymbol> result,
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (2)
467if (symbol is not IPropertySymbol and not IFieldSymbol) 1109if (emptySymbol is not IFieldSymbol and not IPropertySymbol)
src\Analyzers\CSharp\Analyzers\UseDeconstruction\CSharpUseDeconstructionDiagnosticAnalyzer.cs (3)
173foreach (var element in tupleType.TupleElements) 212foreach (var element in tupleType.TupleElements) 267if (member is not IFieldSymbol field)
src\Analyzers\CSharp\Analyzers\UsePrimaryConstructor\CSharpUsePrimaryConstructorDiagnosticAnalyzer.cs (3)
93if (member is not IFieldSymbol and not IPropertySymbol) 175if (_candidateMembersToRemove.Any(kvp => kvp.Key is IFieldSymbol) && 176_candidateMembersToRemove.All(kvp => kvp.Key is IFieldSymbol))
src\Analyzers\CSharp\Analyzers\UseSystemThreadingLock\CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs (5)
88using var fieldsArray = TemporaryArray<(IFieldSymbol field, VariableDeclaratorSyntax declarator, CodeStyleOption2<bool> option)>.Empty; 92if (member is not IFieldSymbol 141IFieldSymbol, 152if (context.ContainingSymbol is not IFieldSymbol fieldSymbol) 172var fieldReference = fieldReferenceOperation.Field.OriginalDefinition;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ParenthesizedExpressionSyntaxExtensions.cs (1)
313if (exprSymbol is not IFieldSymbol { IsConst: true })
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (1)
687if (castedSymbol is not IFieldSymbol and not ILocalSymbol and not IParameterSymbol and not IParameterSymbol { RefKind: RefKind.Ref })
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (38)
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordEngine.cs (1)
107.OfType<IFieldSymbol>()
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordHelpers.cs (15)
26ImmutableArray<IFieldSymbol> expectedComparedFields) 78ImmutableArray<IFieldSymbol> expectedHashedFields) 228ImmutableArray<IFieldSymbol> fields, 249Field: IFieldSymbol referencedField 448{ Instance: IInstanceReferenceOperation, Field: IFieldSymbol field } 493private static ImmutableArray<IFieldSymbol> GetEqualizedFields( 506using var _1 = ArrayBuilder<IFieldSymbol>.GetInstance(out var fields); 729ArrayBuilder<IFieldSymbol> builder) 787ArrayBuilder<IFieldSymbol> builder, 883ArrayBuilder<IFieldSymbol> builder) 921ArrayBuilder<IFieldSymbol> builder) 931var field = UnwrapPropertyToField(memberReference1.Member); 960ArrayBuilder<IFieldSymbol> builder, 1125private static IFieldSymbol? UnwrapPropertyToField(ISymbol propertyOrField) 1129IFieldSymbol field => field,
src\Analyzers\CSharp\CodeFixes\DisambiguateSameVariable\CSharpDisambiguateSameVariableCodeFixProvider.cs (1)
109where m is IFieldSymbol or IPropertySymbol
src\Analyzers\CSharp\CodeFixes\MakeMemberRequired\CSharpMakeMemberRequiredCodeFixProvider.cs (1)
78else if (fieldOrPropertySymbol is IFieldSymbol fieldSymbol)
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (3)
184else if (symbol is IFieldSymbol { IsImplicitlyDeclared: false, DeclaringSyntaxReferences.Length: > 0 } field) 194else if (symbol is IFieldSymbol { CorrespondingTupleField: IFieldSymbol { Locations: [{ IsInSource: true } location] } })
src\Analyzers\CSharp\CodeFixes\ReplaceDefaultLiteral\CSharpReplaceDefaultLiteralCodeFixProvider.cs (1)
88type.GetMembers("None").FirstOrDefault() is IFieldSymbol field && IsZero(field.ConstantValue))
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (1)
278IMethodSymbol or IPropertySymbol or IEventSymbol or IFieldSymbol =>
src\Analyzers\CSharp\CodeFixes\UseSystemThreadingLock\CSharpUseSystemThreadingLockCodeFixProvider.cs (1)
93if (semanticModel.GetDeclaredSymbol(variableDeclarator, cancellationToken) is not IFieldSymbol field)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (1)
277if (symbol is IFieldSymbol
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (2)
97protected override TDeclarationNode AddField<TDeclarationNode>(TDeclarationNode destination, IFieldSymbol field, CSharpCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) 642public override SyntaxNode CreateFieldDeclaration(IFieldSymbol field, CodeGenerationDestination destination, CSharpCodeGenerationContextInfo info, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\EnumMemberGenerator.cs (3)
24internal static EnumDeclarationSyntax AddEnumMemberTo(EnumDeclarationSyntax destination, IFieldSymbol enumMember, CSharpCodeGenerationContextInfo info, CancellationToken cancellationToken) 54IFieldSymbol enumMember, 74SyntaxGenerator generator, EnumDeclarationSyntax? destination, IFieldSymbol enumMember)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\FieldGenerator.cs (5)
56IFieldSymbol field, 72IFieldSymbol field, 88IFieldSymbol field, CSharpCodeGenerationContextInfo info, CancellationToken cancellationToken) 111private static EqualsValueClauseSyntax? GenerateEqualsValue(SyntaxGenerator generator, IFieldSymbol field) 122private static SyntaxTokenList GenerateModifiers(IFieldSymbol field, CSharpCodeGenerationContextInfo info)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\NamedTypeGenerator.cs (1)
122members = members.WhereAsArray(m => m is not IPropertySymbol and not IFieldSymbol || !primaryConstructor.Parameters.Any(static (p, m) => p.Name == m.Name, m));
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ITypeSymbolExtensions.TypeSyntaxGeneratorVisitor.cs (1)
254foreach (var element in symbol.TupleElements)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (1)
1464case IFieldSymbol field:
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (1)
SymbolKey\SymbolKeyMetadataVsSourceTests.cs (1)
370ResolveAndVerifyTypeSymbol(list[3], (originalSymbols[3] as IFieldSymbol).Type, model, comp20);
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (46)
CodeGen\CodeGenDeconstructTests.cs (12)
3611var field = (IFieldSymbol)model.GetDeclaredSymbol(decl); 5404var xType = ((IFieldSymbol)xSymbol).Type; 5411var yType = ((IFieldSymbol)ySymbol).Type; 5437var xType = ((IFieldSymbol)xSymbol).Type; 5444var yType = ((IFieldSymbol)ySymbol).Type; 5569var xType = ((IFieldSymbol)xSymbol).Type; 5617var yType = ((IFieldSymbol)ySymbol).Type; 5648var x1Type = ((IFieldSymbol)x1Symbol).Type; 5657var x2Type = ((IFieldSymbol)x2Symbol).Type; 5692var x1Type = ((IFieldSymbol)x1Symbol).Type; 5701var x2Type = ((IFieldSymbol)x2Symbol).Type;
CodeGen\CodeGenTupleTest.cs (34)
3645foreach (var item in type.TupleElements) 5883Assert.All(tupleWithoutNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()), 5960Assert.All(tupleWithoutNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()), 5979Assert.All(tupleWithNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()), 5998Assert.All(tupleWithSomeNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()), 6016Assert.All(tupleWithNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()), 6068Assert.All(tuple8WithoutNames.GetMembers().OfType<IFieldSymbol>().Where(f => f.Name != "Rest").Select(f => f.Locations.FirstOrDefault()), 6093Assert.All(tuple8WithNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()), 6118Assert.All(tuple9WithoutNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()), 6144Assert.All(tuple9WithNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()), 6176Assert.All(tuple9WithNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()), 6200Assert.All(tupleWithoutNames.GetMembers().OfType<IFieldSymbol>().Select(f => f.Locations.FirstOrDefault()), 6600var tuple1 = (INamedTypeSymbol)comp.SourceModule.GlobalNamespace.GetMember<INamedTypeSymbol>("C").GetMember<IFieldSymbol>("F").Type; 6635var tuple1 = (INamedTypeSymbol)((IFieldSymbol)comp.GetMember("Program.F")).Type; 6677var tuple1 = (INamedTypeSymbol)((IFieldSymbol)comp.GetMember("Program.F")).Type; 6716var tuple1 = (INamedTypeSymbol)((IFieldSymbol)comp.GetMember("Program.F")).Type; 6757var tuple1 = (INamedTypeSymbol)((IFieldSymbol)comp.GetMember("Program.F")).Type; 6835var tuple1 = (INamedTypeSymbol)((IFieldSymbol)comp.GetMember("Program.F")).Type; 6865var tuple1 = (INamedTypeSymbol)((IFieldSymbol)comp.GetMember("Program.F")).Type; 6904var tuple1 = (INamedTypeSymbol)((IFieldSymbol)comp.GetMember("Program.F")).Type; 14252m1Tuple.GetMember<IFieldSymbol>("Rest").Type.ToTestDisplayString()); 14259m1Tuple.GetMember<IFieldSymbol>("Rest").Type.ToTestDisplayString()); 14268m2Tuple.GetMember<IFieldSymbol>("Rest").Type.ToTestDisplayString()); 14270var f1Tuple = (INamedTypeSymbol)test.GetMember<IFieldSymbol>("F1").Type; 14277f1Tuple = (INamedTypeSymbol)((IFieldSymbol)symbolInfo.Symbol).Type; 14282f1Tuple.GetMember<IFieldSymbol>("Rest").Type.ToTestDisplayString()); 14296p1Tuple.GetMember<IFieldSymbol>("Rest").Type.ToTestDisplayString()); 14440e1Tuple.GetMember<IFieldSymbol>("Rest").Type.ToTestDisplayString()); 22859AssertEx.SetEqual(xSymbol.GetMembers().OfType<IFieldSymbol>().Select(f => f.Name), 27419VerifyTypeFromVisualBasic((INamedTypeSymbol)((IFieldSymbol)containingType.GetMembers("F0").Single()).Type, TupleUnderlyingTypeValue.Null, "System.ValueTuple", "System.ValueTuple"); 27420VerifyTypeFromVisualBasic((INamedTypeSymbol)((IFieldSymbol)containingType.GetMembers("F1").Single()).Type, TupleUnderlyingTypeValue.Distinct, "(System.Int32, System.Int32)", "(System.Int32, System.Int32)"); 27421VerifyTypeFromVisualBasic((INamedTypeSymbol)((IFieldSymbol)containingType.GetMembers("F2").Single()).Type, TupleUnderlyingTypeValue.Distinct, "(System.Int32 A, System.Int32 B)", "(A As System.Int32, B As System.Int32)"); 27422VerifyTypeFromVisualBasic((INamedTypeSymbol)((IFieldSymbol)containingType.GetMembers("F3").Single()).Type, TupleUnderlyingTypeValue.Distinct, "(System.Object, System.Object, System.Object, System.Object, System.Object, System.Object, System.Object, System.Object)", "(System.Object, System.Object, System.Object, System.Object, System.Object, System.Object, System.Object, System.Object)"); 27423VerifyTypeFromVisualBasic((INamedTypeSymbol)((IFieldSymbol)containingType.GetMembers("F4").Single()).Type, TupleUnderlyingTypeValue.Distinct, "(System.Object, System.Object B, System.Object, System.Object D, System.Object, System.Object F, System.Object, System.Object H)", "(System.Object, B As System.Object, System.Object, D As System.Object, System.Object, F As System.Object, System.Object, H As System.Object)");
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (6)
Emit\NumericIntPtrTests.cs (6)
11228var symbol = (IFieldSymbol)model.GetSymbolInfo(cref).Symbol; 11253var symbol = (IFieldSymbol)model.GetSymbolInfo(cref).Symbol; 11298var symbol = (IFieldSymbol)model.GetSymbolInfo(cref).Symbol;
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (36)
Diagnostics\GetDiagnosticsTests.cs (2)
1721foreach (var field in namedType.GetMembers().OfType<IFieldSymbol>())
Semantics\OutVarTests.cs (28)
26431Assert.Equal("System.Int32", ((IFieldSymbol)compilation.GetSemanticModel(tree).GetDeclaredSymbol(x1Decl.VariableDesignation())).Type.ToTestDisplayString()); 27028Assert.Equal("System.Int32", ((IFieldSymbol)compilation.GetSemanticModel(tree).GetDeclaredSymbol(x1Decl.VariableDesignation())).Type.ToTestDisplayString()); 32202var x1 = (IFieldSymbol)model.GetDeclaredSymbol(x1Decl.VariableDesignation()); 32232var b = (IFieldSymbol)model.GetDeclaredSymbol(tree.GetRoot().DescendantNodes().OfType<VariableDeclaratorSyntax>().Where(d => d.Identifier.ValueText == "b").Single()); 32243var x1 = (IFieldSymbol)model.GetDeclaredSymbol(x1Decl.VariableDesignation()); 32272var b = (IFieldSymbol)model.GetDeclaredSymbol(tree.GetRoot().DescendantNodes().OfType<VariableDeclaratorSyntax>().Where(d => d.Identifier.ValueText == "b").Single()); 32283var x1 = (IFieldSymbol)model.GetDeclaredSymbol(x1Decl.VariableDesignation()); 32312var a = (IFieldSymbol)model.GetDeclaredSymbol(tree.GetRoot().DescendantNodes().OfType<VariableDeclaratorSyntax>().Where(d => d.Identifier.ValueText == "a").Single()); 32323var x1 = (IFieldSymbol)model.GetDeclaredSymbol(x1Decl.VariableDesignation()); 32331x1 = (IFieldSymbol)model.GetDeclaredSymbol(x1Decl.VariableDesignation()); 32369var x1 = (IFieldSymbol)model.GetDeclaredSymbol(x1Decl.VariableDesignation()); 32386var b = (IFieldSymbol)model.GetDeclaredSymbol(bDecl); 32389x1 = (IFieldSymbol)model.GetDeclaredSymbol(x1Decl.VariableDesignation()); 32438var x1 = (IFieldSymbol)model.GetDeclaredSymbol(x1Decl.VariableDesignation()); 32488var x1 = (IFieldSymbol)model.GetDeclaredSymbol(x1Decl.VariableDesignation()); 32753var local = (IFieldSymbol)symbol;
Semantics\PatternMatchingTestBase.cs (2)
265var local = (IFieldSymbol)symbol;
Semantics\PatternMatchingTests_Global.cs (2)
901Assert.Equal("System.Int32", ((IFieldSymbol)compilation.GetSemanticModel(tree).GetDeclaredSymbol(x1Decl)).Type.ToTestDisplayString()); 1459Assert.Equal("System.Int32", ((IFieldSymbol)compilation.GetSemanticModel(tree).GetDeclaredSymbol(x1Decl)).Type.ToTestDisplayString());
Semantics\RecordTests.cs (2)
906var xBackingField = (IFieldSymbol)c.GetMember("<X>k__BackingField");
Microsoft.CodeAnalysis.CSharp.Features (87)
Completion\CompletionProviders\EnumAndCompletionListTagCompletionProvider.cs (2)
189var fields = type.GetMembers().OfType<IFieldSymbol>().Where(f => f.IsConst).Where(f => f.HasConstantValue); 224if (member is IFieldSymbol { IsStatic: true } field)
Completion\CompletionProviders\PropertySubPatternCompletionProvider.cs (1)
130IFieldSymbol field => field.Type,
Completion\CompletionProviders\TupleNameCompletionProvider.cs (1)
104var field = type.TupleElements[index];
ConvertPrimaryToRegularConstructor\ConvertPrimaryToRegularConstructorCodeRefactoringProvider.cs (7)
176ImmutableDictionary<IParameterSymbol, IFieldSymbol> CreateSynthesizedFields() 178using var _1 = PooledDictionary<Location, IFieldSymbol>.GetInstance(out var locationToField); 179using var _2 = PooledDictionary<IParameterSymbol, IFieldSymbol>.GetInstance(out var result); 186if (member is IFieldSymbol { IsImplicitlyDeclared: true, Locations: [var location, ..] } field) 199var synthesizedField = CodeGenerationSymbolFactory.CreateFieldSymbol( 296.Select(p => parameterToSynthesizedFields.TryGetValue(p, out var field) ? field : null) 350if (!parameterToSynthesizedFields.TryGetValue(parameter, out var field))
ConvertProgram\ConvertProgramTransform_TopLevelStatements.cs (2)
257var field = (IFieldSymbol?)semanticModel.GetDeclaredSymbol(variable, cancellationToken);
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (1)
2554IFieldSymbol { ContainingType.TypeKind: TypeKind.Enum }
EncapsulateField\CSharpEncapsulateFieldService.cs (6)
93var field = semanticModel.GetDeclaredSymbol(declarator, cancellationToken) as IFieldSymbol; 123protected override async Task<ImmutableArray<IFieldSymbol>> GetFieldsAsync(Document document, TextSpan span, CancellationToken cancellationToken) 147return declarators.Select(d => semanticModel.GetDeclaredSymbol(d, cancellationToken) as IFieldSymbol) 156protected override (string fieldName, string propertyName) GenerateFieldAndPropertyNames(IFieldSymbol field) 190private static bool IsNew(IFieldSymbol field)
GenerateConstructorFromMembers\CSharpGenerateConstructorFromMembersCodeRefactoringProvider.cs (2)
56protected override IFieldSymbol? TryMapToWritableInstanceField(IPropertySymbol property, CancellationToken cancellationToken) 72return property.ContainingType.GetMembers(accessedMemberName).FirstOrDefault() as IFieldSymbol;
InitializeParameter\CSharpInitializeMemberFromPrimaryConstructorParameterCodeRefactoringProvider.cs (5)
106if (memberWithName is IFieldSymbol { IsConst: false, DeclaringSyntaxReferences: [var syntaxRef1, ..] } field && 164yield return siblingFieldOrProperty is IFieldSymbol ? fieldAction : propertyAction; 165yield return siblingFieldOrProperty is IFieldSymbol ? propertyAction : fieldAction; 177yield return siblingFieldOrProperty is IFieldSymbol ? allFieldsAction : allPropertiesAction; 178yield return siblingFieldOrProperty is IFieldSymbol ? allPropertiesAction : allFieldsAction;
InitializeParameter\CSharpInitializeMemberFromPrimaryConstructorParameterCodeRefactoringProvider_Update.cs (4)
105IFieldSymbol => GetAddContext<IFieldSymbol>(compilation, parameter, cancellationToken), 124else if (fieldOrProperty is IFieldSymbol field) 241else if (fieldOrProperty is IFieldSymbol field)
LanguageServices\CSharpSymbolDisplayService.SymbolDescriptionBuilder.cs (2)
107else if (symbol is IFieldSymbol field) 170IFieldSymbol symbol)
QuickInfo\CSharpSemanticQuickInfoProvider.cs (2)
110case IFieldSymbol { HasConstantValue: true }: return default; 114case IFieldSymbol:
ReplacePropertyWithMethods\CSharpReplacePropertyWithMethodsService.cs (4)
43IFieldSymbol propertyBackingField, 68IFieldSymbol? propertyBackingField, 109IFieldSymbol? propertyBackingField, 167IFieldSymbol? propertyBackingField,
SignatureHelp\AttributeSignatureHelpProvider.cs (3)
177var type = namedParameter is IFieldSymbol ? ((IFieldSymbol)namedParameter).Type : ((IPropertySymbol)namedParameter).Type; 182namedParameter is IFieldSymbol ? SymbolDisplayPartKind.FieldName : SymbolDisplayPartKind.PropertyName,
SignatureHelp\TupleConstructionSignatureHelpProvider.cs (1)
183foreach (var element in tupleType.TupleElements)
src\Analyzers\CSharp\Analyzers\MakeStructFieldsWritable\CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs (1)
80.OfType<IFieldSymbol>()
src\Analyzers\CSharp\Analyzers\MakeStructReadOnly\CSharpMakeStructReadOnlyDiagnosticAnalyzer.cs (1)
104if (member is IFieldSymbol field)
src\Analyzers\CSharp\Analyzers\UseAutoProperty\CSharpUseAutoPropertyAnalyzer.cs (4)
67ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> ineligibleFieldUsageIfOutsideProperty, 133if (symbolInfo.GetAnySymbol() is not IFieldSymbol { ContainingType.TypeKind: TypeKind.Struct }) 162if (symbol is IFieldSymbol field) 260HashSet<IFieldSymbol> result,
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (2)
467if (symbol is not IPropertySymbol and not IFieldSymbol) 1109if (emptySymbol is not IFieldSymbol and not IPropertySymbol)
src\Analyzers\CSharp\Analyzers\UseDeconstruction\CSharpUseDeconstructionDiagnosticAnalyzer.cs (3)
173foreach (var element in tupleType.TupleElements) 212foreach (var element in tupleType.TupleElements) 267if (member is not IFieldSymbol field)
src\Analyzers\CSharp\Analyzers\UsePrimaryConstructor\CSharpUsePrimaryConstructorDiagnosticAnalyzer.cs (3)
93if (member is not IFieldSymbol and not IPropertySymbol) 175if (_candidateMembersToRemove.Any(kvp => kvp.Key is IFieldSymbol) && 176_candidateMembersToRemove.All(kvp => kvp.Key is IFieldSymbol))
src\Analyzers\CSharp\Analyzers\UseSystemThreadingLock\CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs (5)
88using var fieldsArray = TemporaryArray<(IFieldSymbol field, VariableDeclaratorSyntax declarator, CodeStyleOption2<bool> option)>.Empty; 92if (member is not IFieldSymbol 141IFieldSymbol, 152if (context.ContainingSymbol is not IFieldSymbol fieldSymbol) 172var fieldReference = fieldReferenceOperation.Field.OriginalDefinition;
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordEngine.cs (1)
107.OfType<IFieldSymbol>()
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordHelpers.cs (15)
26ImmutableArray<IFieldSymbol> expectedComparedFields) 78ImmutableArray<IFieldSymbol> expectedHashedFields) 228ImmutableArray<IFieldSymbol> fields, 249Field: IFieldSymbol referencedField 448{ Instance: IInstanceReferenceOperation, Field: IFieldSymbol field } 493private static ImmutableArray<IFieldSymbol> GetEqualizedFields( 506using var _1 = ArrayBuilder<IFieldSymbol>.GetInstance(out var fields); 729ArrayBuilder<IFieldSymbol> builder) 787ArrayBuilder<IFieldSymbol> builder, 883ArrayBuilder<IFieldSymbol> builder) 921ArrayBuilder<IFieldSymbol> builder) 931var field = UnwrapPropertyToField(memberReference1.Member); 960ArrayBuilder<IFieldSymbol> builder, 1125private static IFieldSymbol? UnwrapPropertyToField(ISymbol propertyOrField) 1129IFieldSymbol field => field,
src\Analyzers\CSharp\CodeFixes\DisambiguateSameVariable\CSharpDisambiguateSameVariableCodeFixProvider.cs (1)
109where m is IFieldSymbol or IPropertySymbol
src\Analyzers\CSharp\CodeFixes\MakeMemberRequired\CSharpMakeMemberRequiredCodeFixProvider.cs (1)
78else if (fieldOrPropertySymbol is IFieldSymbol fieldSymbol)
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (3)
184else if (symbol is IFieldSymbol { IsImplicitlyDeclared: false, DeclaringSyntaxReferences.Length: > 0 } field) 194else if (symbol is IFieldSymbol { CorrespondingTupleField: IFieldSymbol { Locations: [{ IsInSource: true } location] } })
src\Analyzers\CSharp\CodeFixes\ReplaceDefaultLiteral\CSharpReplaceDefaultLiteralCodeFixProvider.cs (1)
88type.GetMembers("None").FirstOrDefault() is IFieldSymbol field && IsZero(field.ConstantValue))
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (1)
278IMethodSymbol or IPropertySymbol or IEventSymbol or IFieldSymbol =>
src\Analyzers\CSharp\CodeFixes\UseSystemThreadingLock\CSharpUseSystemThreadingLockCodeFixProvider.cs (1)
93if (semanticModel.GetDeclaredSymbol(variableDeclarator, cancellationToken) is not IFieldSymbol field)
UseAutoProperty\CSharpUseAutoPropertyCodeFixProvider.cs (1)
82IFieldSymbol fieldSymbol,
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (35)
Semantics\AccessCheckTests.cs (27)
748IFieldSymbol privField = classA.GetMembers("priv").Single() as IFieldSymbol; 749IFieldSymbol pubField = classA.GetMembers("pub").Single() as IFieldSymbol; 750IFieldSymbol protField = classA.GetMembers("prot").Single() as IFieldSymbol; 751ITypeSymbol karrayType = (classA.GetMembers("karray").Single() as IFieldSymbol).Type; 752ITypeSymbol aarrayType = (classA.GetMembers("aarray").Single() as IFieldSymbol).Type; 753ITypeSymbol kptrType = (classA.GetMembers("kptr").Single() as IFieldSymbol).Type; 754ITypeSymbol aptrType = (classA.GetMembers("aptr").Single() as IFieldSymbol).Type; 755ITypeSymbol kinreturnfuncptrType = (classA.GetMembers("kinreturnfuncptr").Single() as IFieldSymbol).Type; 756ITypeSymbol kinparamfuncptr1Type = (classA.GetMembers("kinparamfuncptr1").Single() as IFieldSymbol).Type; 757ITypeSymbol kinparamfuncptr2Type = (classA.GetMembers("kinparamfuncptr2").Single() as IFieldSymbol).Type; 758ITypeSymbol afuncptrType = (classA.GetMembers("afuncptr").Single() as IFieldSymbol).Type; 759ITypeSymbol kenumType = (classA.GetMembers("kenum").Single() as IFieldSymbol).Type; 760ITypeSymbol aenumType = (classA.GetMembers("aenum").Single() as IFieldSymbol).Type; 764ITypeSymbol unknownType = (classA.GetMembers("unknowntype").Single() as IFieldSymbol).Type; 903IFieldSymbol Outer_Inner_Field = Outer_Inner.GetMembers("Field").Single() as IFieldSymbol; 904IFieldSymbol Outer_Pointer = Outer.GetMembers("Pointer").Single() as IFieldSymbol; 905IFieldSymbol Outer_Protected = Outer.GetMembers("Protected").Single() as IFieldSymbol; 906IFieldSymbol Outer_ProtectedInternal = Outer.GetMembers("ProtectedInternal").Single() as IFieldSymbol; 907IFieldSymbol Outer_PrivateProtected = Outer.GetMembers("PrivateProtected").Single() as IFieldSymbol;
Semantics\NativeIntegerTests.cs (2)
15393var symbol = (IFieldSymbol)model.GetSymbolInfo(cref).Symbol;
Semantics\RecordStructTests.cs (4)
1769var xBackingField = (IFieldSymbol)c.GetMember("<X>k__BackingField"); 1816var xBackingField = (IFieldSymbol)c.GetMember("<X>k__BackingField");
Semantics\UnsafeTests.cs (2)
8238Assert.Equal(intPointerType.GetPublicSymbol(), ((IFieldSymbol)receiverSymbol).Type); 8296Assert.Equal(intPointerType.GetPublicSymbol(), ((IFieldSymbol)receiverSymbol).Type);
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (106)
Compilation\SemanticModelAPITests.cs (9)
796var xSym = mainType.GetMembers("x").Single() as IFieldSymbol; 1721var fieldQ = classQ.GetMember<IFieldSymbol>("q"); 4378var fieldX = (IFieldSymbol)classA.GetMembers("X").Single().ISymbol; 4379var fieldY = (IFieldSymbol)classA.GetMembers("Y").Single().ISymbol; 4380var fieldZ = (IFieldSymbol)classA.GetMembers("Z").Single().ISymbol;
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (18)
949var fSymbol = model.GetDeclaredSymbol(fieldDecl.Declaration.Variables[0]) as IFieldSymbol; 3647var fSymbol = model.GetDeclaredSymbol((EnumMemberDeclarationSyntax)enumMemberDecl); 4083var fieldB = classM.GetMember<IFieldSymbol>("B"); 4914var element = (IFieldSymbol)model.GetDeclaredSymbol(decl); 4937var element = (IFieldSymbol)model.GetDeclaredSymbol(decl); 4960var element = (IFieldSymbol)model.GetDeclaredSymbol(decl); 4995var element = (IFieldSymbol)model.GetDeclaredSymbol(decl); 5041var element = (IFieldSymbol)model.GetDeclaredSymbol(decl); 5090var element = (IFieldSymbol)model.GetDeclaredSymbol(decl); 5113var element = (IFieldSymbol)model.GetDeclaredSymbol(decl);
Compilation\SemanticModelGetSemanticInfoTests.cs (12)
4621var symbol = (IFieldSymbol)semanticInfo.Symbol; 4687var symbol = (IFieldSymbol)semanticInfo.Symbol; 4724var symbol = (IFieldSymbol)semanticInfo.Symbol; 4760var symbol = (IFieldSymbol)semanticInfo.Symbol; 4796var symbol = (IFieldSymbol)semanticInfo.Symbol; 4828var symbol = (IFieldSymbol)semanticInfo.Symbol;
Compilation\SymbolVisitorTests.cs (3)
81public override void VisitField(IFieldSymbol symbol) 256public override string VisitField(IFieldSymbol symbol) 447public override int VisitField(IFieldSymbol symbol, StringBuilder argument)
Symbols\Source\DeclaringSyntaxNodeTests.cs (16)
203var f = s1.GetMembers("f").Single() as IFieldSymbol; 238foreach (IFieldSymbol f in c1.GetMembers().OfType<IFieldSymbol>()) 459foreach (IFieldSymbol f in c2.GetMembers().OfType<IFieldSymbol>()) 475foreach (IFieldSymbol f in c3.GetMembers().OfType<IFieldSymbol>()) 542if (memb is IFieldSymbol) 544var fld = (IFieldSymbol)memb; 552var fieldT = c1.GetMembers("t").Single() as IFieldSymbol; 565if (memb is IFieldSymbol) 567var fld = (IFieldSymbol)memb;
Symbols\Source\FieldTests.cs (4)
498var goo = (IFieldSymbol)s.GetMember("goo").GetPublicSymbol(); 518var goo = (IFieldSymbol)s.GetMember("goo").GetPublicSymbol();
Symbols\Source\NullablePublicAPITests.cs (6)
147return c.GetMembers().OfType<IFieldSymbol>().ToArray(); 2786Assert.Equal(PublicNullableAnnotation.Annotated, ((IFieldSymbol)symInfo.Symbol).NullableAnnotation); 2787Assert.Equal(PublicNullableAnnotation.Annotated, ((IFieldSymbol)symInfo.Symbol).Type.NullableAnnotation); 2791Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((IFieldSymbol)symInfo.Symbol).NullableAnnotation); 2792Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((IFieldSymbol)symInfo.Symbol).Type.NullableAnnotation); 4218Assert.Equal(SpecialType.System_String, ((IFieldSymbol)symbolInfo.Symbol).Type.SpecialType);
Symbols\SymbolEqualityTests.cs (38)
225var type1 = ((IFieldSymbol)comp.GetMember("A.field1")).Type; 226var type2 = ((IFieldSymbol)comp.GetMember("A.field2")).Type; 249var type1 = ((IFieldSymbol)comp.GetMember("A.field1")).Type; 250var type2 = ((IFieldSymbol)comp.GetMember("A.field2")).Type; 285var type1 = ((IFieldSymbol)comp.GetMember("A.field1")).Type; 286var type2 = ((IFieldSymbol)comp.GetMember("A.field2")).Type; 309var type1 = ((IFieldSymbol)comp.GetMember("A.field1")).Type; 310var type2 = ((IFieldSymbol)comp.GetMember("A.field2")).Type; 344var type1comp1 = ((IFieldSymbol)comp1.GetMember("A.field1")).Type; 345var type1comp2 = ((IFieldSymbol)comp2.GetMember("A.field1")).Type; 346var type2 = ((IFieldSymbol)comp2.GetMember("B.field2")).Type; 376var symbol1 = ((IFieldSymbol)comp.GetMember("A.field1")).Type; 424var field1 = (IFieldSymbol)member1; 425var field2 = (IFieldSymbol)member2; 454var type1 = ((IFieldSymbol)model.GetDeclaredSymbol(member1Syntax.Declaration.Variables[0])).Type; 455var type2 = ((IFieldSymbol)model.GetDeclaredSymbol(member2Syntax.Declaration.Variables[0])).Type; 485var type1 = ((IFieldSymbol)model.GetDeclaredSymbol(member1Syntax.Declaration.Variables[0])).Type; 486var type2 = ((IFieldSymbol)model.GetDeclaredSymbol(member2Syntax.Declaration.Variables[0])).Type; 528var type1 = ((IFieldSymbol)model.GetDeclaredSymbol(member1Syntax.Declaration.Variables[0])).Type; 529var type2 = ((IFieldSymbol)model.GetDeclaredSymbol(member2Syntax.Declaration.Variables[0])).Type; 559var type1 = ((IFieldSymbol)model.GetDeclaredSymbol(member1Syntax.Declaration.Variables[0])).Type; 560var type2 = ((IFieldSymbol)model.GetDeclaredSymbol(member2Syntax.Declaration.Variables[0])).Type; 630var type1 = ((IFieldSymbol)model.GetDeclaredSymbol(member1Syntax.Declaration.Variables[0])).Type; 631var type2 = ((IFieldSymbol)model.GetDeclaredSymbol(member2Syntax.Declaration.Variables[0])).Type; 679var type1 = ((IFieldSymbol)model.GetDeclaredSymbol(member1Syntax.Declaration.Variables[0])).Type; 680var type2 = ((IFieldSymbol)model.GetDeclaredSymbol(member2Syntax.Declaration.Variables[0])).Type; 686var field1 = (IFieldSymbol)type1.GetMembers()[0]; 687var field2 = (IFieldSymbol)type2.GetMembers()[0]; 731var type1 = ((IFieldSymbol)model.GetDeclaredSymbol(member1Syntax.Declaration.Variables[0])).Type; 732var type2 = ((IFieldSymbol)model.GetDeclaredSymbol(member2Syntax.Declaration.Variables[0])).Type; 781var field1 = (IFieldSymbol)((INamedTypeSymbol)model.GetDeclaredSymbol(member1Syntax)).GetMembers("field").Single(); // A<T!>! A<T>.field 782var field2 = (IFieldSymbol)model.GetSymbolInfo(member2Syntax).Symbol; // A<T!>! A<T!>.field
Microsoft.CodeAnalysis.CSharp.Test.Utilities (1)
Extensions.cs (1)
815return ((IFieldSymbol)symbol).Type;
Microsoft.CodeAnalysis.CSharp.Workspaces (19)
Classification\SyntaxClassification\NameSyntaxClassifier.cs (2)
195case IFieldSymbol fieldSymbol: 234private static string GetClassificationForField(IFieldSymbol fieldSymbol)
Recommendations\CSharpRecommendationServiceRunner.cs (1)
616.WhereAsArray(symbol => symbol is INamespaceOrTypeSymbol or IFieldSymbol { IsConst: true }
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ParenthesizedExpressionSyntaxExtensions.cs (1)
313if (exprSymbol is not IFieldSymbol { IsConst: true })
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (1)
687if (castedSymbol is not IFieldSymbol and not ILocalSymbol and not IParameterSymbol and not IParameterSymbol { RefKind: RefKind.Ref })
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (1)
277if (symbol is IFieldSymbol
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (2)
97protected override TDeclarationNode AddField<TDeclarationNode>(TDeclarationNode destination, IFieldSymbol field, CSharpCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) 642public override SyntaxNode CreateFieldDeclaration(IFieldSymbol field, CodeGenerationDestination destination, CSharpCodeGenerationContextInfo info, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\EnumMemberGenerator.cs (3)
24internal static EnumDeclarationSyntax AddEnumMemberTo(EnumDeclarationSyntax destination, IFieldSymbol enumMember, CSharpCodeGenerationContextInfo info, CancellationToken cancellationToken) 54IFieldSymbol enumMember, 74SyntaxGenerator generator, EnumDeclarationSyntax? destination, IFieldSymbol enumMember)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\FieldGenerator.cs (5)
56IFieldSymbol field, 72IFieldSymbol field, 88IFieldSymbol field, CSharpCodeGenerationContextInfo info, CancellationToken cancellationToken) 111private static EqualsValueClauseSyntax? GenerateEqualsValue(SyntaxGenerator generator, IFieldSymbol field) 122private static SyntaxTokenList GenerateModifiers(IFieldSymbol field, CSharpCodeGenerationContextInfo info)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\NamedTypeGenerator.cs (1)
122members = members.WhereAsArray(m => m is not IPropertySymbol and not IFieldSymbol || !primaryConstructor.Parameters.Any(static (p, m) => p.Name == m.Name, m));
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ITypeSymbolExtensions.TypeSyntaxGeneratorVisitor.cs (1)
254foreach (var element in symbol.TupleElements)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (1)
1464case IFieldSymbol field:
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (6)
CodeGeneration\SyntaxGeneratorTests.cs (6)
3783var symbolX = (IFieldSymbol)symbolC.GetMembers("X").First(); 3784var symbolY = (IFieldSymbol)symbolC.GetMembers("Y").First(); 3785var symbolZ = (IFieldSymbol)symbolC.GetMembers("Z").First();
Microsoft.CodeAnalysis.EditorFeatures (1)
RenameTracking\RenameTrackingTaggerProvider.TrackingSession.cs (1)
237((IFieldSymbol)sourceSymbol).ContainingType.IsTupleType &&
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (91)
CodeGeneration\CodeGenerationTests.cs (1)
70var field = CodeGenerationSymbolFactory.CreateFieldSymbol(
SymbolFinder\FindSymbolAtPositionTests.cs (2)
61var fieldSymbol = Assert.IsAssignableFrom<IFieldSymbol>(await FindSymbolAtPositionAsync(workspace));
Utilities\SymbolEquivalenceComparerTests.cs (88)
54var intField1 = (IFieldSymbol)type.GetMembers("intField1").Single(); 55var intArrayField1 = (IFieldSymbol)type.GetMembers("intArrayField1").Single(); 56var stringArrayField1 = (IFieldSymbol)type.GetMembers("stringArrayField1").Single(); 57var intArrayArrayField1 = (IFieldSymbol)type.GetMembers("intArrayArrayField1").Single(); 58var intArrayRank2Field1 = (IFieldSymbol)type.GetMembers("intArrayRank2Field1").Single(); 59var int32Field1 = (IFieldSymbol)type.GetMembers("int32Field1").Single(); 61var intField2 = (IFieldSymbol)type.GetMembers("intField2").Single(); 62var intArrayField2 = (IFieldSymbol)type.GetMembers("intArrayField2").Single(); 63var stringArrayField2 = (IFieldSymbol)type.GetMembers("stringArrayField2").Single(); 64var intArrayArrayField2 = (IFieldSymbol)type.GetMembers("intArrayArrayField2").Single(); 65var intArrayRank2Field2 = (IFieldSymbol)type.GetMembers("intArrayRank2Field2").Single(); 66var int32Field2 = (IFieldSymbol)type.GetMembers("int32Field2").Single(); 127var csharpIntField1 = (IFieldSymbol)csharpType.GetMembers("intField1").Single(); 128var csharpIntArrayField1 = (IFieldSymbol)csharpType.GetMembers("intArrayField1").Single(); 129var csharpStringArrayField1 = (IFieldSymbol)csharpType.GetMembers("stringArrayField1").Single(); 130var csharpIntArrayArrayField1 = (IFieldSymbol)csharpType.GetMembers("intArrayArrayField1").Single(); 131var csharpIntArrayRank2Field1 = (IFieldSymbol)csharpType.GetMembers("intArrayRank2Field1").Single(); 132var csharpInt32Field1 = (IFieldSymbol)csharpType.GetMembers("int32Field1").Single(); 134var vbIntField1 = (IFieldSymbol)vbType.GetMembers("intField1").Single(); 135var vbIntArrayField1 = (IFieldSymbol)vbType.GetMembers("intArrayField1").Single(); 136var vbStringArrayField1 = (IFieldSymbol)vbType.GetMembers("stringArrayField1").Single(); 137var vbIntArrayArrayField1 = (IFieldSymbol)vbType.GetMembers("intArrayArrayField1").Single(); 138var vbIntArrayRank2Field1 = (IFieldSymbol)vbType.GetMembers("intArrayRank2Field1").Single(); 139var vbInt32Field1 = (IFieldSymbol)vbType.GetMembers("int32Field1").Single(); 287var intInstantiation1 = (IFieldSymbol)typeC.GetMembers("intInstantiation1").Single(); 288var stringInstantiation = (IFieldSymbol)typeC.GetMembers("stringInstantiation").Single(); 289var instanceInstantiation = (IFieldSymbol)typeC.GetMembers("instanceInstantiation").Single(); 290var intInstantiation2 = (IFieldSymbol)typeD.GetMembers("intInstantiation2").Single(); 1346var a1 = ((IFieldSymbol)t1.GetMembers("A").Single()).Type; 1347var b1 = ((IFieldSymbol)t1.GetMembers("B").Single()).Type; 1348var c1 = ((IFieldSymbol)t1.GetMembers("C").Single()).Type; 1349var d1 = ((IFieldSymbol)t1.GetMembers("D").Single()).Type; 1350var a2 = ((IFieldSymbol)t2.GetMembers("A").Single()).Type; 1351var b2 = ((IFieldSymbol)t2.GetMembers("B").Single()).Type; 1352var c2 = ((IFieldSymbol)t2.GetMembers("C").Single()).Type; 1353var d2 = ((IFieldSymbol)t2.GetMembers("D").Single()).Type; 1410var a1 = ((IFieldSymbol)t1.GetMembers("A").Single()).Type; 1411var b1 = ((IFieldSymbol)t1.GetMembers("B").Single()).Type; 1412var c1 = ((IFieldSymbol)t1.GetMembers("C").Single()).Type; 1413var d1 = ((IFieldSymbol)t1.GetMembers("D").Single()).Type; 1414var a2 = ((IFieldSymbol)t2.GetMembers("A").Single()).Type; 1415var b2 = ((IFieldSymbol)t2.GetMembers("B").Single()).Type; 1416var c2 = ((IFieldSymbol)t2.GetMembers("C").Single()).Type; 1417var d2 = ((IFieldSymbol)t2.GetMembers("D").Single()).Type; 1473var a1 = ((IFieldSymbol)t1.GetMembers("A").Single()).Type; 1474var b1 = ((IFieldSymbol)t1.GetMembers("B").Single()).Type; 1475var c1 = ((IFieldSymbol)t1.GetMembers("C").Single()).Type; 1476var d1 = ((IFieldSymbol)t1.GetMembers("D").Single()).Type; 1477var a2 = ((IFieldSymbol)t2.GetMembers("A").Single()).Type; 1478var b2 = ((IFieldSymbol)t2.GetMembers("B").Single()).Type; 1479var c2 = ((IFieldSymbol)t2.GetMembers("C").Single()).Type; 1480var d2 = ((IFieldSymbol)t2.GetMembers("D").Single()).Type; 1536var a1 = ((IFieldSymbol)t1.GetMembers("A").Single()).Type; 1537var b1 = ((IFieldSymbol)t1.GetMembers("B").Single()).Type; 1538var c1 = ((IFieldSymbol)t1.GetMembers("C").Single()).Type; 1539var d1 = ((IFieldSymbol)t1.GetMembers("D").Single()).Type; 1540var a2 = ((IFieldSymbol)t2.GetMembers("A").Single()).Type; 1541var b2 = ((IFieldSymbol)t2.GetMembers("B").Single()).Type; 1542var c2 = ((IFieldSymbol)t2.GetMembers("C").Single()).Type; 1543var d2 = ((IFieldSymbol)t2.GetMembers("D").Single()).Type;
Microsoft.CodeAnalysis.EditorFeatures2.UnitTests (2)
Workspaces\TryFindSourceDefinitionTests.vb (2)
60Dim field = DirectCast(Type.GetMembers("field").Single(), IFieldSymbol) 104Dim field = DirectCast(Type.GetMembers("field").Single(), IFieldSymbol)
Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler (1)
AbstractTypeParameterChecker.cs (1)
80public sealed override void VisitField(IFieldSymbol symbol)
Microsoft.CodeAnalysis.Features (172)
AddImport\SymbolReferenceFinder.cs (1)
330.Any(static (m, self) => (m is IFieldSymbol || m is IPropertySymbol) &&
Completion\Providers\AbstractContextVariableArgumentProvider.cs (1)
61if (symbol.IsKind(SymbolKind.Field, out IFieldSymbol? field))
Completion\Providers\AbstractObjectInitializerCompletionProvider.cs (1)
120if (symbol is IFieldSymbol fieldSymbol)
Completion\Providers\ImportCompletionProvider\AbstractExtensionMethodImportCompletionProvider.cs (1)
107IFieldSymbol fieldSymbol => fieldSymbol.Type,
ConvertAutoPropertyToFullProperty\AbstractConvertAutoPropertyToFullPropertyCodeRefactoringProvider.cs (3)
59var fields = propertySymbol.ContainingType.GetMembers().OfType<IFieldSymbol>(); 60var field = fields.FirstOrDefault(f => propertySymbol.Equals(f.AssociatedSymbol)); 102var newField = CodeGenerationSymbolFactory.CreateFieldSymbol(
ConvertTupleToStruct\AbstractConvertTupleToStructCodeRefactoringProvider.cs (7)
122ImmutableArray<IFieldSymbol> fields, 466var tupleFieldNames = tupleType.TupleElements.SelectAsArray<IFieldSymbol, string>(f => f.Name); 481var tupleFieldNames = tupleType.TupleElements.SelectAsArray<IFieldSymbol, string>(f => f.Name); 671StringComparer comparer, ImmutableArray<IFieldSymbol> fields1, ImmutableArray<IFieldSymbol> fields2) 886var arguments = tupleType.TupleElements.SelectAsArray<IFieldSymbol, SyntaxNode>( 923ImmutableArray<IFieldSymbol> fields, SyntaxGenerator generator,
EditAndContinue\AbstractEditAndContinueAnalyzer.cs (6)
323SymbolKind.Field => GetDisplayName((IFieldSymbol)symbol), 350internal virtual string GetDisplayName(IFieldSymbol symbol) 2394protected static bool ReturnTypesEquivalent(IFieldSymbol oldField, IFieldSymbol newField, bool exact) 2440return ReturnTypesEquivalent((IFieldSymbol)oldMember, (IFieldSymbol)newMember, exact);
EditAndContinue\Utilities\Extensions.cs (4)
170=> property.ContainingType.GetMembers().Any(static (member, property) => member is IFieldSymbol field && field.AssociatedSymbol == property, property); 186public static IFieldSymbol? GetPrimaryParameterBackingField(this IParameterSymbol parameter) 187=> (IFieldSymbol?)parameter.ContainingType.GetMembers().FirstOrDefault( 188static (member, parameter) => member is IFieldSymbol field && ParsePrimaryParameterBackingFieldName(field.Name, out var paramName) && paramName == parameter.Name, parameter);
EmbeddedLanguages\EmbeddedLanguageDetector.cs (1)
438return symbol is IFieldSymbol or IPropertySymbol &&
EncapsulateField\AbstractEncapsulateFieldService.cs (21)
41protected abstract Task<ImmutableArray<IFieldSymbol>> GetFieldsAsync(Document document, TextSpan span, CancellationToken cancellationToken); 50var firstField = fields[0]; 73foreach (var field in fields) 81private ImmutableArray<CodeAction> EncapsulateAllFields(Document document, ImmutableArray<IFieldSymbol> fields) 93private ImmutableArray<CodeAction> EncapsulateOneField(Document document, IFieldSymbol field) 110Document document, ImmutableArray<IFieldSymbol> fields, 140private async Task<Solution> EncapsulateFieldsInCurrentProcessAsync(Document document, ImmutableArray<IFieldSymbol> fields, bool updateReferences, CancellationToken cancellationToken) 146foreach (var field in fields) 153if (field.GetSymbolKey(cancellationToken).Resolve(compilation, cancellationToken: cancellationToken).Symbol is not IFieldSymbol currentField) 168IFieldSymbol field, 172var originalField = field; 186field = (IFieldSymbol)field.GetSymbolKey(cancellationToken).Resolve(compilation, cancellationToken: cancellationToken).Symbol!; 207field = (IFieldSymbol)semanticModel.GetRequiredDeclaredSymbol(newDeclaration, cancellationToken); 230bool updateReferences, Solution solution, Document document, IFieldSymbol field, string finalFieldName, string generatedPropertyName, CancellationToken cancellationToken) 254field = (IFieldSymbol)field.GetSymbolKey(cancellationToken).Resolve(compilation, cancellationToken: cancellationToken).Symbol!; 276IFieldSymbol field, 318IFieldSymbol field, 339IFieldSymbol field, 362protected abstract (string fieldName, string propertyName) GenerateFieldAndPropertyNames(IFieldSymbol field); 377protected static IMethodSymbol CreateSet(string originalFieldName, IFieldSymbol field, SyntaxGenerator factory) 396protected static IMethodSymbol CreateGet(string originalFieldName, IFieldSymbol field, SyntaxGenerator factory)
EncapsulateField\IEncapsulateFieldService.cs (1)
18Task<Solution> EncapsulateFieldsAsync(Document document, ImmutableArray<IFieldSymbol> fields, bool updateReferences, CancellationToken cancellationToken);
ExtractMethod\MethodExtractor.Analyzer.cs (2)
921var field = (IFieldSymbol)pair.Key;
GenerateConstructorFromMembers\AbstractGenerateConstructorFromMembersCodeRefactoringProvider.cs (1)
61protected abstract IFieldSymbol? TryMapToWritableInstanceField(IPropertySymbol property, CancellationToken cancellationToken);
GenerateFromMembers\AbstractGenerateFromMembersCodeRefactoringProvider.cs (3)
63IFieldSymbol field => IsViableField(field), 72IFieldSymbol field => IsViableField(field) && !field.IsConst, 77private static bool IsViableField(IFieldSymbol field)
GenerateType\AbstractGenerateTypeService.Editor.cs (1)
621if (symbol is IFieldSymbol field)
InitializeParameter\AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs (7)
127if (siblingFieldOrProperty is IFieldSymbol) 143if (siblingFieldOrProperty is IFieldSymbol) 199var field = CreateField(parameter, accessibilityModifiersRequired, rules); 277private IFieldSymbol CreateField( 467else if (fieldOrProperty is IFieldSymbol field) 471codeGenerator.GetInfo(GetAddContext<IFieldSymbol>(parameter, blockStatement, typeDeclaration, cancellationToken), options, root.SyntaxTree.Options), 699if (memberWithName is IFieldSymbol field &&
InitializeParameter\AbstractInitializeParameterCodeRefactoringProvider.cs (1)
230if (memberReference.Member is IFieldSymbol or IPropertySymbol)
InlineMethod\AbstractInlineMethodRefactoringProvider.cs (1)
585&& semanticModel.GetExistingSymbols(node, cancellationToken).SingleOrDefault() is IFieldSymbol fieldSymbol)
LanguageServices\AnonymousTypeDisplayService\AbstractStructuralTypeDisplayService.StructuralTypeCollectorVisitor.cs (2)
37public override void VisitField(IFieldSymbol symbol) 98foreach (var field in symbol.TupleElements)
LanguageServices\SymbolDisplayService\AbstractSymbolDisplayService.AbstractSymbolDescriptionBuilder.cs (3)
315else if (symbol is IFieldSymbol field) 538private async Task AddDescriptionForFieldAsync(IFieldSymbol symbol) 558private async Task<ImmutableArray<SymbolDisplayPart>> GetFieldPartsAsync(IFieldSymbol symbol)
MetadataAsSource\AbstractMetadataAsSourceService.WrappedFieldSymbol.cs (5)
14private sealed class WrappedFieldSymbol(IFieldSymbol fieldSymbol, IDocumentationCommentFormattingService docCommentFormattingService) : AbstractWrappedSymbol(fieldSymbol, canImplementImplicitly: false, docCommentFormattingService: docCommentFormattingService), IFieldSymbol 16private readonly IFieldSymbol _symbol = fieldSymbol; 18public new IFieldSymbol OriginalDefinition => _symbol.OriginalDefinition; 20public IFieldSymbol CorrespondingTupleField => null;
MetadataAsSource\AbstractMetadataAsSourceService.WrappedNamedTypeSymbol.cs (2)
47SymbolKind.Field => new WrappedFieldSymbol((IFieldSymbol)m, docCommentFormattingService), 86public ImmutableArray<IFieldSymbol> TupleElements => _symbol.TupleElements;
NameTupleElement\AbstractNameTupleElementCodeRefactoringProvider.cs (1)
72var element = elements[argumentIndex];
PullMemberUp\MembersPuller.cs (2)
185else if (member is IFieldSymbol fieldSymbol) 498if (selectedMember is IFieldSymbol fieldSymbol)
QuickInfo\CommonSemanticQuickInfoProvider.ErrorVisitor.cs (1)
32public override bool VisitField(IFieldSymbol symbol)
ReplacePropertyWithMethods\AbstractReplacePropertyWithMethodsService.cs (5)
30Document document, IPropertySymbol property, SyntaxNode propertyDeclaration, IFieldSymbol propertyBackingField, string desiredGetMethodName, string desiredSetMethodName, CancellationToken cancellationToken); 39protected static SyntaxNode GetFieldReference(SyntaxGenerator generator, IFieldSymbol propertyBackingField) 57IPropertySymbol property, IFieldSymbol propertyBackingField, 82private readonly IFieldSymbol _propertyBackingField; 99IFieldSymbol propertyBackingField,
ReplacePropertyWithMethods\IReplacePropertyWithMethodsService.cs (2)
24IPropertySymbol property, IFieldSymbol propertyBackingField, 31IFieldSymbol propertyBackingField,
ReplacePropertyWithMethods\ReplacePropertyWithMethodsCodeRefactoringProvider.cs (9)
119private static ImmutableDictionary<IPropertySymbol, IFieldSymbol?> CreateDefinitionToBackingFieldMap(IEnumerable<ReferencedSymbol> propertyReferences) 121var definitionToBackingField = ImmutableDictionary.CreateBuilder<IPropertySymbol, IFieldSymbol?>(SymbolEquivalenceComparer.Instance); 127var backingField = GetBackingField(property); 160private static IFieldSymbol? GetBackingField(IPropertySymbol property) 201ImmutableDictionary<IPropertySymbol, IFieldSymbol?> propertyToBackingField, 221ImmutableDictionary<IPropertySymbol, IFieldSymbol?> propertyToBackingField, 242IDictionary<IPropertySymbol, IFieldSymbol?> propertyToBackingField, 300ImmutableDictionary<IPropertySymbol, IFieldSymbol?> definitionToBackingField, 350IDictionary<IPropertySymbol, IFieldSymbol?> definitionToBackingField,
RQName\RQNodeBuilder.cs (2)
25IFieldSymbol fieldSymbol => BuildField(fieldSymbol), 87private static RQMember? BuildField(IFieldSymbol symbol)
Shared\Extensions\ISymbolExtensions_2.cs (1)
45publicIcon = ((IFieldSymbol)symbol).IsConst ? Glyph.ConstantPublic : Glyph.FieldPublic;
Shared\Utilities\ExtractTypeHelpers.cs (2)
215var field = member as IFieldSymbol;
src\Analyzers\Core\Analyzers\MakeFieldReadonly\AbstractMakeFieldReadonlyDiagnosticAnalyzer.cs (13)
42var fieldStateMap = new ConcurrentDictionary<IFieldSymbol, (bool isCandidate, bool written)>(); 88var field = (IFieldSymbol)symbolContext.Symbol; 117if (member is IFieldSymbol field && fieldStateMap.TryRemove(field.OriginalDefinition, out var value)) 141if (member is IFieldSymbol field && 157bool IsCandidateField(IFieldSymbol symbol) 188static bool IsDataContractSerializable(IFieldSymbol symbol, INamedTypeSymbol? dataContractAttribute, INamedTypeSymbol? dataMemberAttribute) 198void UpdateFieldStateOnWrite(IFieldSymbol field) 207(bool isCandidate, bool written) TryGetOrInitializeFieldState(IFieldSymbol fieldSymbol, AnalyzerOptions options, CancellationToken cancellationToken) 221IFieldSymbol field, 240private static Location GetDiagnosticLocation(IFieldSymbol field) 263var field = fieldReference.Field; 299private static CodeStyleOption2<bool> GetCodeStyleOption(IFieldSymbol field, AnalyzerOptions options, out Location diagnosticLocation)
src\Analyzers\Core\Analyzers\PopulateSwitch\PopulateSwitchStatementHelpers.cs (1)
158if (member is not IFieldSymbol fieldSymbol || fieldSymbol.Type.SpecialType != SpecialType.None)
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (5)
289foreach (var field in initializer.InitializedFields) 483if (isInlineArray && member is IFieldSymbol { IsStatic: false }) 705case IPropertySymbol or IFieldSymbol: 733/// Backing fields have a non-null <see cref="IFieldSymbol.AssociatedSymbol"/>. 852return ((IFieldSymbol)memberSymbol).AssociatedSymbol == null;
src\Analyzers\Core\Analyzers\UseAutoProperty\AbstractUseAutoPropertyAnalyzer.cs (20)
46private static readonly ObjectPool<ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>>> s_fieldToUsageLocationPool = new(() => []); 63protected static void AddFieldUsage(ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> fieldWrites, IFieldSymbol field, SyntaxNode location) 66private static void ClearAndFree(ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> multiMap) 100SemanticModel semanticModel, IMethodSymbol accessor, HashSet<string> fieldNames, HashSet<IFieldSymbol> result, CancellationToken cancellationToken); 103HashSet<string> fieldNames, ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> ineligibleFieldUsageIfOutsideProperty, SemanticModel semanticModel, SyntaxNode codeBlock, CancellationToken cancellationToken); 131if (member is IFieldSymbol 229ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> fieldReads, 230ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> fieldWrites, 243if (semanticModel.GetSymbolInfo(identifierName, cancellationToken).Symbol is not IFieldSymbol field) 275using var _ = PooledHashSet<IFieldSymbol>.GetInstance(out var set); 291using var _ = PooledHashSet<IFieldSymbol>.GetInstance(out var set); 297private IFieldSymbol? CheckFieldAccessExpression( 316IFieldSymbol field, 483var getterField = getterFields.TrivialField ?? getterFields.NonTrivialFields.Single(); 499protected IFieldSymbol? TryGetDirectlyAccessedFieldSymbol( 539ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> ineligibleFieldUsageIfOutsideProperty, 540ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> fieldReads, 541ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> fieldWrites, 544using var _1 = PooledHashSet<IFieldSymbol>.GetInstance(out var reportedFields);
src\Analyzers\Core\Analyzers\UseAutoProperty\AccessedFields.cs (5)
16IFieldSymbol? TrivialField, 17ImmutableArray<IFieldSymbol> NonTrivialFields) 21public AccessedFields(IFieldSymbol? trivialField) : this(trivialField, []) 28public AccessedFields Where<TArg>(Func<IFieldSymbol, TArg, bool> predicate, TArg arg) 32public bool Contains(IFieldSymbol field)
src\Analyzers\Core\Analyzers\UseAutoProperty\AnalysisResult.cs (1)
33IFieldSymbol Field,
src\Analyzers\Core\Analyzers\UseExplicitTupleName\UseExplicitTupleNameDiagnosticAnalyzer.cs (6)
49var field = fieldReferenceOperation.Field; 54var namedField = GetNamedField(field.ContainingType, field, context.CancellationToken); 76private static IFieldSymbol? GetNamedField( 77INamedTypeSymbol containingType, IFieldSymbol unnamedField, CancellationToken cancellationToken) 85var fieldSymbol = (IFieldSymbol)member;
src\Analyzers\Core\CodeFixes\GenerateConstructor\AbstractGenerateConstructorService.State.cs (1)
545if (symbol is IFieldSymbol field)
src\Analyzers\Core\CodeFixes\GenerateVariable\AbstractGenerateVariableService.CodeAction.cs (1)
92var fieldSymbol = CodeGenerationSymbolFactory.CreateFieldSymbol(
src\Analyzers\Core\CodeFixes\GenerateVariable\AbstractGenerateVariableService.State.cs (1)
414=> symbol is IFieldSymbol field && field.IsReadOnly;
src\Analyzers\Core\CodeFixes\ImplementInterface\ImplementHelpers.cs (4)
27.OfType<IFieldSymbol>() 43ImmutableArray<IFieldSymbol> fields, 65bool IsAssignedToFieldOrProperty(ImmutableArray<IFieldSymbol> fields, ImmutableArray<IPropertySymbol> properties, IParameterSymbol parameter) 68bool IsAssignedToField(IFieldSymbol field, IParameterSymbol parameter)
src\Analyzers\Core\CodeFixes\ImplementInterface\ImplementInterfaceGenerator_DisposePattern.cs (3)
120IFieldSymbol disposedValueField) 138IFieldSymbol disposedValueField) 233private static async Task<IFieldSymbol> CreateDisposedValueFieldAsync(
src\Analyzers\Core\CodeFixes\MakeFieldReadonly\AbstractMakeFieldReadonlyCodeFixProvider.cs (2)
80var symbol = (IFieldSymbol?)model.GetDeclaredSymbol(declarator, cancellationToken);
UseAutoProperty\AbstractUseAutoPropertyCodeFixProvider.cs (7)
55IFieldSymbol fieldSymbol, 187field = (IFieldSymbol?)field.GetSymbolKey(cancellationToken).Resolve(compilation, cancellationToken: cancellationToken).Symbol; 271private async Task<(IFieldSymbol? fieldSymbol, IPropertySymbol? propertySymbol)> MapDiagnosticToCurrentSolutionAsync( 287var fieldSymbol = (IFieldSymbol)fieldSemanticModel.GetRequiredDeclaredSymbol(declarator, cancellationToken); 302fieldSymbol = fieldSymbol.GetSymbolKey(cancellationToken).Resolve(currentCompilation, cancellationToken: cancellationToken).GetAnySymbol() as IFieldSymbol; 366IFieldSymbol field, LightweightRenameLocations renameLocations, TPropertyDeclaration propertyDeclaration, CancellationToken cancellationToken)
ValueTracking\ValueTracker.cs (2)
30or IFieldSymbol 87case IFieldSymbol:
Microsoft.CodeAnalysis.Features.UnitTests (5)
FindUsages\DefinitionItemFactoryTests.cs (5)
665var c = compilation.GetMember<IFieldSymbol>("C.F").Type; 702var tuple = (INamedTypeSymbol)compilation.GetMember<IFieldSymbol>("C.F").Type; 764var tuple = (INamedTypeSymbol)compilation.GetMember<IFieldSymbol>("C.F").Type; 820var type = (INamedTypeSymbol)compilation.GetMember<IFieldSymbol>("C.F").Type; 874var type = (INamedTypeSymbol)compilation.GetMember<IFieldSymbol>("C.F").Type;
Microsoft.CodeAnalysis.Remote.ServiceHub (3)
Services\EncapsulateField\RemoteEncapsulateFieldService.cs (3)
37using var _ = ArrayBuilder<IFieldSymbol>.GetInstance(out var fields); 42var resolved = SymbolKey.ResolveString(key, compilation, cancellationToken: cancellationToken).GetAnySymbol() as IFieldSymbol;
Microsoft.CodeAnalysis.Test.Utilities (24)
Compilation\CompilationDifference.cs (1)
169var actual = EmitResult.Baseline.SynthesizedMembers.Single(e => e.Key.ToString() == typeName).Value.Where(s => s.Kind == SymbolKind.Field).Select(s => (IFieldSymbol)s.GetISymbol()).Select(f => f.Name + ": " + f.Type);
Compilation\OperationTreeVerifier.cs (1)
1542foreach (var local in operation.InitializedFields)
Compilation\TestOperationVisitor.cs (2)
1105foreach (var field in operation.InitializedFields) 1536case IFieldSymbol field:
CompilationVerifier.cs (1)
748.Select(f => $"{((IFieldSymbol)f.GetISymbol()).Type.ToString()} {f.Name}")
Diagnostics\CouldHaveMoreSpecificTypeAnalyzer.cs (8)
47Dictionary<IFieldSymbol, HashSet<INamedTypeSymbol>> fieldsSourceTypes = new Dictionary<IFieldSymbol, HashSet<INamedTypeSymbol>>(); 140foreach (IFieldSymbol initializedField in initializer.InitializedFields) 151foreach (IFieldSymbol field in fieldsSourceTypes.Keys) 232private static void AssignTo(IOperation target, Dictionary<ILocalSymbol, HashSet<INamedTypeSymbol>> localsSourceTypes, Dictionary<IFieldSymbol, HashSet<INamedTypeSymbol>> fieldsSourceTypes, IOperation sourceValue) 237private static void AssignTo(IOperation target, Dictionary<ILocalSymbol, HashSet<INamedTypeSymbol>> localsSourceTypes, Dictionary<IFieldSymbol, HashSet<INamedTypeSymbol>> fieldsSourceTypes, ITypeSymbol sourceType) 247IFieldSymbol targetField = ((IFieldReferenceOperation)target).Field; 298private void Report(CompilationAnalysisContext context, IFieldSymbol field, ITypeSymbol moreSpecificType, DiagnosticDescriptor descriptor)
Diagnostics\FieldCouldBeReadOnlyAnalyzer.cs (11)
39HashSet<IFieldSymbol> assignedToFields = new HashSet<IFieldSymbol>(); 40HashSet<IFieldSymbol> mightBecomeReadOnlyFields = new HashSet<IFieldSymbol>(); 91IFieldSymbol field = (IFieldSymbol)symbolContext.Symbol; 103foreach (IFieldSymbol couldBeReadOnlyField in mightBecomeReadOnlyFields) 111private static void AssignTo(IOperation target, bool inConstructor, ITypeSymbol staticConstructorType, HashSet<IFieldSymbol> assignedToFields, HashSet<IFieldSymbol> mightBecomeReadOnlyFields) 125IFieldSymbol targetField = fieldReference.Field; 142private void Report(CompilationAnalysisContext context, IFieldSymbol field, DiagnosticDescriptor descriptor)
Microsoft.CodeAnalysis.UnitTests (1)
Diagnostics\OperationTests.cs (1)
168ImmutableArray<IFieldSymbol>.Empty, ImmutableArray<ILocalSymbol>.Empty,
Microsoft.CodeAnalysis.VisualBasic (37)
Binding\MemberSemanticModel.vb (1)
563Public Overrides Function GetDeclaredSymbol(declarationSyntax As EnumMemberDeclarationSyntax, Optional cancellationToken As CancellationToken = Nothing) As IFieldSymbol
Compilation\SemanticModel.vb (1)
2547Public MustOverride Overloads Function GetDeclaredSymbol(declarationSyntax As EnumMemberDeclarationSyntax, Optional cancellationToken As CancellationToken = Nothing) As IFieldSymbol
Compilation\SpeculativeSemanticModelWithMemberModel.vb (1)
181Public Overrides Function GetDeclaredSymbol(declarationSyntax As EnumMemberDeclarationSyntax, Optional cancellationToken As CancellationToken = Nothing) As IFieldSymbol
Compilation\SyntaxTreeSemanticModel.vb (2)
1153Public Overrides Function GetDeclaredSymbol(declarationSyntax As EnumMemberDeclarationSyntax, Optional cancellationToken As CancellationToken = Nothing) As IFieldSymbol 1366Dim field = TryCast(Me.GetDeclaredSymbol(identifier, cancellationToken), IFieldSymbol)
Operations\VisualBasicOperationFactory.vb (3)
919Dim field As IFieldSymbol = boundFieldAccess.FieldSymbol 991Dim initializedFields As ImmutableArray(Of IFieldSymbol) = boundFieldInitializer.InitializedFields.As(Of IFieldSymbol)
SymbolDisplay\SymbolDisplayVisitor.Members.vb (3)
11Public Overrides Sub VisitField(symbol As IFieldSymbol) 596Private Sub AddFieldModifiersIfRequired(symbol As IFieldSymbol) 618Dim isConst = symbol.Kind = SymbolKind.Field AndAlso DirectCast(symbol, IFieldSymbol).IsConst
SymbolDisplay\SymbolDisplayVisitor.Types.vb (1)
383Dim elements As ImmutableArray(Of IFieldSymbol) = symbol.TupleElements
Symbols\FieldSymbol.vb (19)
87Public MustOverride ReadOnly Property IsReadOnly As Boolean Implements IFieldSymbol.IsReadOnly 404Private ReadOnly Property IFieldSymbol_AssociatedSymbol As ISymbol Implements IFieldSymbol.AssociatedSymbol 422Private ReadOnly Property IFieldSymbol_IsConst As Boolean Implements IFieldSymbol.IsConst 428Private ReadOnly Property IFieldSymbol_IsVolatile As Boolean Implements IFieldSymbol.IsVolatile, IFieldSymbolInternal.IsVolatile 434Private ReadOnly Property IFieldSymbol_IsRequired As Boolean Implements IFieldSymbol.IsRequired 440Private ReadOnly Property IFieldSymbol_IsFixedSizeBuffer As Boolean Implements IFieldSymbol.IsFixedSizeBuffer 446Private ReadOnly Property IFieldSymbol_FixedSize As Integer Implements IFieldSymbol.FixedSize 455Private ReadOnly Property IFieldSymbol_RefKind As RefKind Implements IFieldSymbol.RefKind 464Private ReadOnly Property IFieldSymbol_RefCustomModifiers As ImmutableArray(Of CustomModifier) Implements IFieldSymbol.RefCustomModifiers 470Private ReadOnly Property IFieldSymbol_Type As ITypeSymbol Implements IFieldSymbol.Type 476Private ReadOnly Property IFieldSymbol_NullableAnnotation As NullableAnnotation Implements IFieldSymbol.NullableAnnotation 482Private ReadOnly Property IFieldSymbol_HasConstantValue As Boolean Implements IFieldSymbol.HasConstantValue 488Private ReadOnly Property IFieldSymbol_ConstantValue As Object Implements IFieldSymbol.ConstantValue 494Private ReadOnly Property IFieldSymbol_CustomModifiers As ImmutableArray(Of CustomModifier) Implements IFieldSymbol.CustomModifiers 500Private ReadOnly Property IFieldSymbol_OriginalDefinition As IFieldSymbol Implements IFieldSymbol.OriginalDefinition 506Private ReadOnly Property IFieldSymbol_CorrespondingTupleField As IFieldSymbol Implements IFieldSymbol.CorrespondingTupleField 512Private ReadOnly Property IFieldSymbol_HasExplicitTupleElementName As Boolean Implements IFieldSymbol.IsExplicitlyNamedTupleElement
Symbols\NamedTypeSymbol.vb (2)
1475Private ReadOnly Property INamedTypeSymbol_TupleElements As ImmutableArray(Of IFieldSymbol) Implements INamedTypeSymbol.TupleElements 1477Return StaticCast(Of IFieldSymbol).From(TupleElements)
Symbols\TypedConstant.vb (2)
80Dim field = TryCast(member, IFieldSymbol) 145Dim field = TryCast(member, IFieldSymbol)
VisualBasicExtensions.vb (2)
599Public Function AssociatedField(eventSymbol As IEventSymbol) As IFieldSymbol 954Public Function GetDeclaredSymbol(semanticModel As SemanticModel, declarationSyntax As EnumMemberDeclarationSyntax, Optional cancellationToken As CancellationToken = Nothing) As IFieldSymbol
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (2)
src\Analyzers\VisualBasic\Analyzers\UseAutoProperty\VisualBasicUseAutoPropertyAnalyzer.vb (2)
51ineligibleFieldUsageIfOutsideProperty As ConcurrentDictionary(Of IFieldSymbol, ConcurrentSet(Of SyntaxNode)), 151Protected Overrides Sub AddAccessedFields(semanticModel As SemanticModel, accessor As IMethodSymbol, fieldNames As HashSet(Of String), result As HashSet(Of IFieldSymbol), cancellationToken As CancellationToken)
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (11)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeGeneration\EnumMemberGenerator.vb (3)
15enumMember As IFieldSymbol, 32Public Function GenerateEnumMemberDeclaration(enumMember As IFieldSymbol, 52Private Function CreateEnumMemberValue(destinationOpt As EnumBlockSyntax, enumMember As IFieldSymbol) As ExpressionSyntax
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeGeneration\FieldGenerator.vb (5)
45field As IFieldSymbol, 56field As IFieldSymbol, 70field As IFieldSymbol, 94Private Function GenerateEqualsValue(generator As SyntaxGenerator, field As IFieldSymbol) As EqualsValueSyntax 103Private Function GenerateModifiers(field As IFieldSymbol,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeGeneration\VisualBasicCodeGenerationService.vb (2)
104field As IFieldSymbol, 555Public Overrides Function CreateFieldDeclaration(field As IFieldSymbol,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\VisualBasicTypeInferenceService.TypeInferrer.vb (1)
615Return CreateResult(DirectCast(symbol, IFieldSymbol).Type)
Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests (33)
CodeGen\CodeGenTuples.vb (33)
5777Assert.True(DirectCast(mFirst, IFieldSymbol).IsExplicitlyNamedTupleElement) 5796Assert.False(DirectCast(mItem1, IFieldSymbol).IsExplicitlyNamedTupleElement) 6898Assert.All(tupleWithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), 6951Assert.All(tupleWithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), 6971Assert.All(tupleWithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), 6992Assert.All(tupleWithSomeNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), 7010Assert.All(tupleWithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), 7035Assert.All(tuple8WithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), 7060Assert.All(tuple8WithNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), 7085Assert.All(tuple9WithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), 7110Assert.All(tuple9WithNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), 7135Assert.All(tuple9WithNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), 7159Assert.All(tupleWithoutNames.GetMembers().OfType(Of IFieldSymbol)().Select(Function(f) f.Locations.FirstOrDefault()), 7544Dim tuple1 = DirectCast(DirectCast(comp.GetMember("Program.F"), IFieldSymbol).Type, INamedTypeSymbol) 7576Dim tuple1 = DirectCast(DirectCast(comp.GetMember("Program.F"), IFieldSymbol).Type, INamedTypeSymbol) 7608Dim tuple1 = DirectCast(DirectCast(comp.GetMember("Program.F"), IFieldSymbol).Type, INamedTypeSymbol) 7643Dim tuple1 = DirectCast(DirectCast(comp.GetMember("Program.F"), IFieldSymbol).Type, INamedTypeSymbol) 7669Dim tuple1 = DirectCast(DirectCast(comp.GetMember("Program.F"), IFieldSymbol).Type, INamedTypeSymbol) 7704Dim tuple1 = DirectCast(DirectCast(comp.GetMember("Program.F"), IFieldSymbol).Type, INamedTypeSymbol) 15384Assert.False(DirectCast(m3Item8, IFieldSymbol).IsExplicitlyNamedTupleElement) 15546Assert.False(DirectCast(m4Item8, IFieldSymbol).IsExplicitlyNamedTupleElement) 15566Assert.True(DirectCast(m4h4, IFieldSymbol).IsExplicitlyNamedTupleElement) 15800Assert.True(DirectCast(m5Item8, IFieldSymbol).IsExplicitlyNamedTupleElement) 16155Assert.False(DirectCast(m8Item8, IFieldSymbol).IsExplicitlyNamedTupleElement) 16175Assert.True(DirectCast(m8Item1, IFieldSymbol).IsExplicitlyNamedTupleElement) 16352Assert.False(DirectCast(m1Item1, IFieldSymbol).IsExplicitlyNamedTupleElement) 16375Assert.False(DirectCast(m2Item1, IFieldSymbol).IsExplicitlyNamedTupleElement) 16395Assert.True(DirectCast(m2a2, IFieldSymbol).IsExplicitlyNamedTupleElement) 23122VerifyTypeFromCSharp(DirectCast(DirectCast(containingType.GetMembers("F0").Single(), IFieldSymbol).Type, INamedTypeSymbol), TupleUnderlyingTypeValue.Nothing, "System.ValueTuple", "()") 23123VerifyTypeFromCSharp(DirectCast(DirectCast(containingType.GetMembers("F1").Single(), IFieldSymbol).Type, INamedTypeSymbol), TupleUnderlyingTypeValue.Nothing, "(System.Int32, System.Int32)", "(System.Int32, System.Int32)") 23124VerifyTypeFromCSharp(DirectCast(DirectCast(containingType.GetMembers("F2").Single(), IFieldSymbol).Type, INamedTypeSymbol), TupleUnderlyingTypeValue.Distinct, "(System.Int32 A, System.Int32 B)", "(A As System.Int32, B As System.Int32)") 23125VerifyTypeFromCSharp(DirectCast(DirectCast(containingType.GetMembers("F3").Single(), IFieldSymbol).Type, INamedTypeSymbol), TupleUnderlyingTypeValue.Nothing, "(System.Object, System.Object, System.Object, System.Object, System.Object, System.Object, System.Object, System.Object)", "(System.Object, System.Object, System.Object, System.Object, System.Object, System.Object, System.Object, System.Object)") 23126VerifyTypeFromCSharp(DirectCast(DirectCast(containingType.GetMembers("F4").Single(), IFieldSymbol).Type, INamedTypeSymbol), TupleUnderlyingTypeValue.Distinct, "(System.Object, System.Object B, System.Object, System.Object D, System.Object, System.Object F, System.Object, System.Object H)", "(System.Object, B As System.Object, System.Object, D As System.Object, System.Object, F As System.Object, System.Object, H As System.Object)")
Microsoft.CodeAnalysis.VisualBasic.Features (24)
Completion\CompletionProviders\EnumCompletionProvider.vb (2)
68If member.Kind = SymbolKind.Field AndAlso DirectCast(member, IFieldSymbol).IsConst AndAlso member.IsEditorBrowsable(options.MemberDisplayOptions.HideAdvancedMembers, syntaxContext.SemanticModel.Compilation) Then 91Dim symbolType = If(TryCast(symbol, IFieldSymbol)?.Type,
EncapsulateField\VisualBasicEncapsulateFieldService.vb (5)
70Protected Overrides Async Function GetFieldsAsync(document As Document, span As TextSpan, cancellationToken As CancellationToken) As Task(Of ImmutableArray(Of IFieldSymbol)) 88OfType(Of IFieldSymbol)(). 106Protected Overrides Function GenerateFieldAndPropertyNames(field As IFieldSymbol) As (fieldName As String, propertyName As String) 122Private Shared Function IsShadows(field As IFieldSymbol) As Boolean 126Private Shared Function MakeUnique(propertyName As String, field As IFieldSymbol) As String
GenerateConstructorFromMembers\VisualBasicGenerateConstructorFromMembersCodeRefactoringProvider.vb (1)
47Protected Overrides Function TryMapToWritableInstanceField([property] As IPropertySymbol, cancellationToken As CancellationToken) As IFieldSymbol
LanguageServices\VisualBasicSymbolDisplayService.SymbolDescriptionBuilder.vb (3)
82ElseIf TypeOf symbol Is IFieldSymbol Then 83Return GetInitializerSourcePartsAsync(DirectCast(symbol, IFieldSymbol)) 141Private Overloads Async Function GetInitializerSourcePartsAsync(symbol As IFieldSymbol) As Task(Of ImmutableArray(Of SymbolDisplayPart))
QuickInfo\VisualBasicSemanticQuickInfoProvider.vb (2)
185ElseIf TypeOf symbol Is IFieldSymbol Then 186Return DirectCast(symbol, IFieldSymbol).Type
ReplacePropertyWithMethods\VisualBasicReplacePropertyWithMethods.vb (4)
30propertyBackingField As IFieldSymbol, 51propertyBackingField As IFieldSymbol, 83propertyBackingField As IFieldSymbol, 116propertyBackingField As IFieldSymbol,
SignatureHelp\AttributeSignatureHelpProvider.vb (3)
146Dim type = If(TypeOf namedParameter Is IFieldSymbol, 147DirectCast(namedParameter, IFieldSymbol).Type, 153If(TypeOf namedParameter Is IFieldSymbol, SymbolDisplayPartKind.FieldName, SymbolDisplayPartKind.PropertyName),
src\Analyzers\VisualBasic\Analyzers\UseAutoProperty\VisualBasicUseAutoPropertyAnalyzer.vb (2)
51ineligibleFieldUsageIfOutsideProperty As ConcurrentDictionary(Of IFieldSymbol, ConcurrentSet(Of SyntaxNode)), 151Protected Overrides Sub AddAccessedFields(semanticModel As SemanticModel, accessor As IMethodSymbol, fieldNames As HashSet(Of String), result As HashSet(Of IFieldSymbol), cancellationToken As CancellationToken)
UseAutoProperty\VisualBasicUseAutoPropertyCodeFixProvider.vb (2)
50fieldSymbol As IFieldSymbol, 94Private Shared Async Function GetFieldInitializerAsync(fieldSymbol As IFieldSymbol, cancellationToken As CancellationToken) As Task(Of (equalsValue As EqualsValueSyntax, asNewClause As AsNewClauseSyntax, arrayBounds As ArgumentListSyntax))
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (5)
Compilation\SemanticModelAPITests.vb (2)
4658Dim symbol = DirectCast(semanticModel.GetSymbolInfo(node).Symbol, IFieldSymbol) 4793Dim symbol = DirectCast(semanticModel.GetSymbolInfo(node).Symbol, IFieldSymbol)
Diagnostics\GetDiagnosticsTests.vb (1)
722For Each field In namedType.GetMembers().OfType(Of IFieldSymbol)
Semantics\RefFieldTests.vb (2)
120Assert.Equal(CodeAnalysis.RefKind.None, DirectCast(field, IFieldSymbol).RefKind) 121Assert.Empty(DirectCast(field, IFieldSymbol).RefCustomModifiers)
Microsoft.CodeAnalysis.VisualBasic.Symbol.UnitTests (1)
SymbolsTests\Source\FieldTests.vb (1)
556Dim goo = DirectCast(s.GetMember(Of FieldSymbol)("goo"), IFieldSymbol)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (17)
Classification\SyntaxClassification\NameSyntaxClassifier.vb (2)
122Dim classification = GetClassificationForField(DirectCast(symbol, IFieldSymbol)) 196Private Shared Function GetClassificationForField(fieldSymbol As IFieldSymbol) As String
Recommendations\VisualBasicRecommendationServiceRunner.vb (2)
85Dim field = DirectCast(symbol, IFieldSymbol) 366Dim associatedSymbol = DirectCast(s, IFieldSymbol).AssociatedSymbol
Rename\VisualBasicRenameRewriterLanguageService.vb (1)
318Dim fieldSymbol = DirectCast(symbol, IFieldSymbol)
Simplification\Reducers\VisualBasicVariableDeclaratorReducer.vb (1)
149(Not TypeOf declaredSymbol Is ILocalSymbol AndAlso Not TypeOf declaredSymbol Is IFieldSymbol) Then
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeGeneration\EnumMemberGenerator.vb (3)
15enumMember As IFieldSymbol, 32Public Function GenerateEnumMemberDeclaration(enumMember As IFieldSymbol, 52Private Function CreateEnumMemberValue(destinationOpt As EnumBlockSyntax, enumMember As IFieldSymbol) As ExpressionSyntax
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeGeneration\FieldGenerator.vb (5)
45field As IFieldSymbol, 56field As IFieldSymbol, 70field As IFieldSymbol, 94Private Function GenerateEqualsValue(generator As SyntaxGenerator, field As IFieldSymbol) As EqualsValueSyntax 103Private Function GenerateModifiers(field As IFieldSymbol,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeGeneration\VisualBasicCodeGenerationService.vb (2)
104field As IFieldSymbol, 555Public Overrides Function CreateFieldDeclaration(field As IFieldSymbol,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\VisualBasicTypeInferenceService.TypeInferrer.vb (1)
615Return CreateResult(DirectCast(symbol, IFieldSymbol).Type)
Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests (3)
CodeGeneration\SyntaxGeneratorTests.vb (3)
3470Dim symbolX = DirectCast(symbolC.GetMembers("X").First(), IFieldSymbol) 3471Dim symbolY = DirectCast(symbolC.GetMembers("Y").First(), IFieldSymbol) 3472Dim symbolZ = DirectCast(symbolC.GetMembers("Z").First(), IFieldSymbol)
Microsoft.CodeAnalysis.Workspaces (96)
Editing\DeclarationModifiers.cs (3)
68IFieldSymbol or 73var field = symbol as IFieldSymbol;
Editing\SyntaxGenerator.cs (3)
131public SyntaxNode FieldDeclaration(IFieldSymbol field) 142public SyntaxNode FieldDeclaration(IFieldSymbol field, SyntaxNode? initializer) 722return FieldDeclaration((IFieldSymbol)symbol);
FindSymbols\FindReferences\Finders\AbstractMemberScopedReferenceFinder.cs (1)
84if (current is IFieldSymbol field)
FindSymbols\FindReferences\Finders\EventSymbolReferenceFinder.cs (1)
27.OfType<IFieldSymbol>()
FindSymbols\FindReferences\Finders\FieldSymbolReferenceFinder.cs (5)
13internal sealed class FieldSymbolReferenceFinder : AbstractReferenceFinder<IFieldSymbol> 15protected override bool CanFind(IFieldSymbol symbol) 19IFieldSymbol symbol, 30IFieldSymbol symbol, 44IFieldSymbol symbol,
FindSymbols\FindReferences\Finders\PropertySymbolReferenceFinder.cs (1)
56if (member is IFieldSymbol field &&
Recommendations\AbstractRecommendationServiceRunner.cs (1)
531: symbols.Where(s => s is not IFieldSymbol).Concat(namedType.TupleElements).ToImmutableArray();
Rename\RenameUtilities.cs (2)
378var fieldSymbol = (IFieldSymbol)symbol;
Rename\SymbolicRenameLocations.ReferenceProcessing.cs (1)
51if (referencedSymbol.Kind == SymbolKind.Field && originalSymbol.Equals(((IFieldSymbol)referencedSymbol).AssociatedSymbol))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\INamedTypeSymbolExtensions.cs (2)
485var fieldSymbol = (IFieldSymbol)symbol;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\IPropertySymbolExtensions.cs (2)
11public static IFieldSymbol? GetBackingFieldIfAny(this IPropertySymbol property) 13.OfType<IFieldSymbol>()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ISymbolExtensions.cs (5)
309=> symbol is IFieldSymbol { ContainingType.IsTupleType: true }; 317IFieldSymbol fieldSymbol => !fieldSymbol.IsReadOnly && !fieldSymbol.IsConst, 323=> symbol is IFieldSymbol { IsRequired: true } or IPropertySymbol { IsRequired: true }; 328IFieldSymbol fieldSymbol => fieldSymbol.Type, 616IFieldSymbol fieldSymbol => fieldSymbol.Type,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ISymbolExtensions.RequiresUnsafeModifierVisitor.cs (1)
44public override bool VisitField(IFieldSymbol symbol)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ITypeSymbolExtensions.cs (1)
695if (member is not IFieldSymbol fieldSymbol)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SymbolSpecification.cs (2)
510if (kind == SymbolKind.Field && ((IFieldSymbol)symbol).IsReadOnly) 518if ((kind == SymbolKind.Field && ((IFieldSymbol)symbol).IsConst) ||
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
66/// <item>Two <see cref="IFieldSymbol"/>s are the "same" if they have
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.FieldSymbolKey.cs (4)
9private sealed class FieldSymbolKey : AbstractSymbolKey<IFieldSymbol> 13public sealed override void Create(IFieldSymbol symbol, SymbolKeyWriter visitor) 20SymbolKeyReader reader, IFieldSymbol? contextualSymbol, out string? failureReason) 31using var result = GetMembersOfNamedType<IFieldSymbol>(containingTypeResolution, metadataName);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
350public override void VisitField(IFieldSymbol fieldSymbol)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.TupleTypeSymbolKey.cs (2)
29foreach (var element in symbol.TupleElements) 43foreach (var element in symbol.TupleElements)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EnumValueUtilities.cs (1)
23.OfType<IFieldSymbol>()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\SymbolEquivalenceComparer.EquivalenceVisitor.cs (8)
120SymbolKind.Field => FieldsAreEquivalent((IFieldSymbol)x, (IFieldSymbol)y, equivalentTypesWithDifferingAssemblies), 151private bool FieldsAreEquivalent(IFieldSymbol x, IFieldSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies) 433var xElement = xElements[i]; 434var yElement = yElements[i]; 450var xElement = xElements[i]; 451var yElement = yElements[i];
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\SymbolEquivalenceComparer.GetHashCodeVisitor.cs (2)
62SymbolKind.Field => CombineHashCodes((IFieldSymbol)x, currentHash), 89private int CombineHashCodes(IFieldSymbol x, int currentHash)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (9)
51public TDeclarationNode AddField<TDeclarationNode>(TDeclarationNode destination, IFieldSymbol field, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode 80public SyntaxNode CreateFieldDeclaration(IFieldSymbol field, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken) 125protected abstract TDeclarationNode AddField<TDeclarationNode>(TDeclarationNode destination, IFieldSymbol field, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode; 145public abstract SyntaxNode CreateFieldDeclaration(IFieldSymbol field, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken); 347IFieldSymbol field => CreateFieldDeclaration(field, codeGenerationDestination, info, cancellationToken), 365IFieldSymbol field => AddField(currentDestination, field, info, availableIndices, cancellationToken), 376var field = members.OfType<IFieldSymbol>().FirstOrDefault(); 402public Task<Document> AddFieldAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IFieldSymbol field, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractFlagsEnumGenerator.cs (17)
13internal abstract class AbstractFlagsEnumGenerator : IComparer<(IFieldSymbol field, ulong value)> 66var allFieldsAndValues = new List<(IFieldSymbol field, ulong value)>(); 69var usedFieldsAndValues = new List<(IFieldSymbol field, ulong value)>(); 77List<(IFieldSymbol field, ulong value)> allFieldsAndValues, 78List<(IFieldSymbol field, ulong value)> usedFieldsAndValues) 128var zeroField = GetZeroField(allFieldsAndValues); 141SyntaxGenerator generator, IFieldSymbol field, INamedTypeSymbol enumType, SpecialType underlyingSpecialType) 156private static IFieldSymbol? GetZeroField(List<(IFieldSymbol field, ulong value)> allFieldsAndValues) 172List<(IFieldSymbol field, ulong value)> allFieldsAndValues) 176foreach (var field in enumType.GetMembers().OfType<IFieldSymbol>()) 195foreach (var field in enumType.GetMembers().OfType<IFieldSymbol>()) 211int IComparer<(IFieldSymbol field, ulong value)>.Compare((IFieldSymbol field, ulong value) x, (IFieldSymbol field, ulong value) y)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (1)
158.OfType<IFieldSymbol>()
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (3)
107public static IFieldSymbol CreateFieldSymbol( 594internal static IFieldSymbol CreateFieldSymbol( 595IFieldSymbol field,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerator.cs (1)
37public static Task<Document> AddFieldDeclarationAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IFieldSymbol field, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\ICodeGenerationService.cs (3)
28SyntaxNode CreateFieldDeclaration(IFieldSymbol field, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken); 59TDeclarationNode AddField<TDeclarationNode>(TDeclarationNode destination, IFieldSymbol field, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode; 139Task<Document> AddFieldAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IFieldSymbol field, CancellationToken cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationAbstractNamedTypeSymbol.cs (1)
23public ImmutableArray<IFieldSymbol> TupleElements { get; protected set; }
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationFieldInfo.cs (6)
13private static readonly ConditionalWeakTable<IFieldSymbol, CodeGenerationFieldInfo> s_fieldToInfoMap = new(); 30IFieldSymbol field, 39private static CodeGenerationFieldInfo GetInfo(IFieldSymbol field) 48public static bool GetIsUnsafe(IFieldSymbol field) 54public static bool GetIsWithEvents(IFieldSymbol field) 60public static SyntaxNode GetInitializer(IFieldSymbol field)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationFieldSymbol.cs (3)
25object constantValue) : CodeGenerationSymbol(containingType?.ContainingAssembly, containingType, attributes, accessibility, modifiers, name), IFieldSymbol 39public new IFieldSymbol OriginalDefinition 47public IFieldSymbol CorrespondingTupleField => null;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions.cs (1)
90IFieldSymbol field => field.Type,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_CreateEqualsMethod.cs (1)
506.OfType<IFieldSymbol>()
Microsoft.CodeAnalysis.Workspaces.UnitTests (26)
FindReferencesTests.cs (2)
129var symbol = (IFieldSymbol)(await project.GetCompilationAsync()).GetTypeByMetadataName("C").GetMembers("X").First();
SymbolKeyTests.cs (14)
151Assert.True(symbols.Any(s => s is IFieldSymbol { MetadataName: "" })); 167Assert.True(symbols.Any(s => s is IFieldSymbol { MetadataName: "" })); 183Assert.True(symbols.Any(s => s is IFieldSymbol { MetadataName: "" })); 198Assert.False(symbols.Any(s => s is IFieldSymbol { MetadataName: "" })); 213Assert.True(symbols.Any(s => s is IFieldSymbol { MetadataName: "" })); 228Assert.False(symbols.Any(s => s is IFieldSymbol { MetadataName: "" })); 243Assert.True(symbols.Any(s => s is IFieldSymbol { MetadataName: "" })); 258Assert.False(symbols.Any(s => s is IFieldSymbol { MetadataName: "" })); 273Assert.True(symbols.Any(s => s is IFieldSymbol { MetadataName: "" })); 359TestRoundTrip(GetDeclaredSymbols(compilation).OfType<IFieldSymbol>().Select(fs => fs.Type), compilation); 377TestRoundTrip(GetDeclaredSymbols(compilation).OfType<IFieldSymbol>().Select(fs => fs.Type), compilation, s => s.ToDisplayString()); 685var refSymbols = GetDeclaredSymbols(compilation).OfType<IFieldSymbol>().Select(f => f.Type).ToList(); 704var symbols = GetDeclaredSymbols(compilation).OfType<IFieldSymbol>().Select(f => f.Type).ToList(); 1257var fields = GetDeclaredSymbols(comp).OfType<IFieldSymbol>().Select(f => f.Type);
UtilityTest\DocumentationCommentIdTests.cs (10)
127CheckDeclarationId<IFieldSymbol>("F:Acme.ValueType.total", compilation, s => s.Name == "total"); 128CheckDeclarationId<IFieldSymbol>("F:Acme.Widget.NestedClass.value", compilation, s => s.Name == "value"); 129CheckDeclarationId<IFieldSymbol>("F:Acme.Widget.message", compilation, s => s.Name == "message"); 130CheckDeclarationId<IFieldSymbol>("F:Acme.Widget.defaultColor", compilation, s => s.Name == "defaultColor"); 131CheckDeclarationId<IFieldSymbol>("F:Acme.Widget.PI", compilation, s => s.Name == "PI"); 132CheckDeclarationId<IFieldSymbol>("F:Acme.Widget.monthlyAverage", compilation, s => s.Name == "monthlyAverage"); 133CheckDeclarationId<IFieldSymbol>("F:Acme.Widget.array1", compilation, s => s.Name == "array1"); 134CheckDeclarationId<IFieldSymbol>("F:Acme.Widget.array2", compilation, s => s.Name == "array2"); 135CheckDeclarationId<IFieldSymbol>("F:Acme.Widget.pCount", compilation, s => s.Name == "pCount"); 136CheckDeclarationId<IFieldSymbol>("F:Acme.Widget.ppValues", compilation, s => s.Name == "ppValues");
Microsoft.Extensions.Logging.Generators (2)
LoggerMessageGenerator.Parser.cs (2)
649foreach (IFieldSymbol fs in currentClassType.GetMembers().OfType<IFieldSymbol>())
Microsoft.Gen.ComplianceReports (2)
Parser.cs (2)
147foreach (var field in typeSymbol.GetMembers().OfType<IFieldSymbol>())
Microsoft.Gen.Logging (2)
Parsing\Parser.cs (1)
652IFieldSymbol fs => fs.Type,
Parsing\Parser.Records.cs (1)
67IFieldSymbol field => new(field.Name, field.Type, Property: null),
Microsoft.Gen.Metrics (3)
Parser.cs (3)
377if (symbol is not IFieldSymbol fieldSymbol || 706var fieldSymbol = member as IFieldSymbol;
Microsoft.Gen.MetricsReports (3)
src\Generators\Microsoft.Gen.Metrics\Parser.cs (3)
377if (symbol is not IFieldSymbol fieldSymbol || 706var fieldSymbol = member as IFieldSymbol;
Microsoft.Interop.LibraryImportGenerator (1)
Analyzers\NativeMarshallingAttributeAnalyzer.cs (1)
171IFieldSymbol field => field.Type,
Microsoft.Interop.SourceGeneration (2)
TypeSymbolExtensions.cs (2)
156foreach (IFieldSymbol field in type.GetMembers().OfType<IFieldSymbol>())
Microsoft.ML.InternalCodeAnalyzer (5)
ContractsCheckAnalyzer.cs (2)
152var field = context.SemanticModel.GetSymbolInfo(access).Symbol as IFieldSymbol;
ContractsCheckNameofFixProvider.cs (1)
139foreach (IFieldSymbol s in type.GetMembers().Where(p => p.Kind == SymbolKind.Field))
InstanceInitializerAnalyzer.cs (2)
42var symbol = (IFieldSymbol)context.Symbol;
Microsoft.VisualStudio.LanguageServices (6)
Library\ObjectBrowser\AbstractDescriptionBuilder.cs (2)
215BuildFieldDeclaration((IFieldSymbol)symbol, options); 241protected abstract void BuildFieldDeclaration(IFieldSymbol fieldSymbol, _VSOBJDESCOPTIONS options);
Library\ObjectBrowser\Lists\MemberListItem.cs (2)
26var fieldSymbol = (IFieldSymbol)symbol;
Progression\GraphBuilder.cs (2)
280node = await GetOrCreateNodeForFieldAsync(graph, (IFieldSymbol)symbol, solution, cancellationToken).ConfigureAwait(false); 635private static async Task<GraphNode> GetOrCreateNodeForFieldAsync(Graph graph, IFieldSymbol field, Solution solution, CancellationToken cancellationToken)
Microsoft.VisualStudio.LanguageServices.CSharp (11)
CodeModel\CSharpCodeModelService_Prototype.cs (7)
31return GetVariablePrototype((IFieldSymbol)symbol, flags); 60return GetVariablePrototype(variableDeclarator, (IFieldSymbol)symbol, flags); 62return GetVariablePrototype(enumMember, (IFieldSymbol)symbol, flags); 223private string GetVariablePrototype(IFieldSymbol symbol, PrototypeFlags flags) 244private string GetVariablePrototype(VariableDeclaratorSyntax node, IFieldSymbol symbol, PrototypeFlags flags) 274private string GetVariablePrototype(EnumMemberDeclarationSyntax node, IFieldSymbol symbol, PrototypeFlags flags) 477private void AppendVariablePrototype(StringBuilder builder, IFieldSymbol symbol, PrototypeFlags flags, string baseName)
ObjectBrowser\DescriptionBuilder.cs (3)
250var fieldSymbol = memberSymbol as IFieldSymbol; 474protected override void BuildFieldDeclaration(IFieldSymbol fieldSymbol, _VSOBJDESCOPTIONS options)
Progression\CSharpProgressionLanguageService.cs (1)
118case IFieldSymbol f: return f.ContainingType.TypeKind == TypeKind.Enum ? null : f.Type;
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests (1)
GlyphExtensionsTests.cs (1)
239var fieldMock = symbolMock.As<IFieldSymbol>();
Microsoft.VisualStudio.LanguageServices.VisualBasic (5)
CodeModel\VisualBasicCodeModelService.vb (1)
1397Dim fieldSymbol = TryCast(symbol, IFieldSymbol)
CodeModel\VisualBasicCodeModelService_Prototype.vb (2)
36Return GetVariablePrototype(DirectCast(symbol, IFieldSymbol), flags) 107Private Shared Function GetVariablePrototype(symbol As IFieldSymbol, flags As PrototypeFlags) As String
ObjectBrowser\DescriptionBuilder.vb (2)
225Protected Overrides Sub BuildFieldDeclaration(fieldSymbol As IFieldSymbol, options As _VSOBJDESCOPTIONS) 333Dim fieldSymbol = TryCast(memberSymbol, IFieldSymbol)
Roslyn.Test.PdbUtilities (1)
EditAndContinue\EditAndContinueTest.GenerationVerifier.cs (1)
138.Select(s => (IFieldSymbol)s.GetISymbol()).Select(f => f.Name + ": " + f.Type);
SemanticSearch.BuildTask (5)
GenerateFilteredReferenceAssembliesTask.cs (5)
200List<IFieldSymbol> fields) 225case IFieldSymbol field: 287var fields = new List<IFieldSymbol>(); 425private static unsafe void UpdateFieldDefinitions(BinaryWriter writer, MetadataReader metadataReader, ImmutableArray<ApiPattern> patterns, ImmutableArray<IFieldSymbol> symbols, int metadataOffset) 433var symbol = GetSymbolWithToken(symbols, ref symbolIndex, handle);
System.Text.Json.SourceGeneration (10)
Helpers\RoslynExtensions.cs (5)
215Debug.Assert(member is IFieldSymbol or IPropertySymbol); 216return member is IFieldSymbol fs ? fs.Type : ((IPropertySymbol)member).Type; 221Debug.Assert(member is IFieldSymbol or IPropertySymbol); 222Debug.Assert(otherMember is IFieldSymbol or IPropertySymbol); 282public static void ResolveNullabilityAnnotations(this IFieldSymbol field, out bool isGetterNonNullable, out bool isSetterNonNullable)
JsonSourceGenerator.Parser.cs (5)
949foreach (IFieldSymbol fieldInfo in members.OfType<IFieldSymbol>()) 1122Debug.Assert(memberInfo is IFieldSymbol or IPropertySymbol); 1242Debug.Assert(memberInfo is IFieldSymbol or IPropertySymbol); 1405case IFieldSymbol fieldInfo:
System.Text.RegularExpressions.Generator (1)
UpgradeToGeneratedRegexCodeFixer.cs (1)
295fieldReferenceOperation.Member is IFieldSymbol fieldSymbol && fieldSymbol.IsConst)
System.Windows.Forms.PrivateSourceGenerators (1)
System\Windows\Forms\SourceGenerators\EnumValidationInfo.cs (1)
20if (member is IFieldSymbol