Binder\Binder_Expressions.cs (16)
56var containingType = memberOpt?.ContainingType;
1483var implicitReceiver = field.IsStatic ? null : ThisReference(node, field.ContainingType, wasCompilerGenerated: true);
1958var declaringType = members[0].ContainingType;
2307NamedTypeSymbol declaringType = member.ContainingType;
4838NamedTypeSymbol containingType = constructor.ContainingType;
4998NamedTypeSymbol baseType = constructor.ContainingType.BaseTypeNoUseSiteDiagnostics;
5123if (resultMember is null || resultMember.ContainingType.SpecialType != SpecialType.System_Object)
5170return constructor.ContainingType is SourceNamedTypeSymbol sourceType &&
6145constructor.ContainingType.HasRequiredMembersError) // An error will be reported on the constructor if from source, or a use-site diagnostic will be reported on the use if from metadata.
6150return constructor.ContainingType.AllRequiredMembers;
6664this.IsSymbolAccessibleConditional(constructor, containingType, ref useSiteInfo, constructor.ContainingType);
8048Debug.Assert(propertySymbol.ContainingType.ExtensionParameter is not null);
8052receiver = CheckAndConvertExtensionReceiver(receiver, propertySymbol.ContainingType.ExtensionParameter, diagnostics);
8862NamedTypeSymbol type = fieldSymbol.ContainingType;
9035if (symbol.ContainingType?.IsInterface == true)
10563return new ErrorPropertySymbol(candidate.ContainingType, propertyType, candidate.Name, candidate.IsIndexer, candidate.IsIndexedProperty);
Binder\Binder_Invocation.cs (7)
1073if (call.ReceiverOpt.Type.IsRestrictedType() && !call.Method.ContainingType.IsInterface && !TypeSymbol.Equals(call.Method.ContainingType, call.ReceiverOpt.Type, TypeCompareKind.ConsiderEverything2))
1075SymbolDistinguisher distinguisher = new SymbolDistinguisher(compilation, call.ReceiverOpt.Type, call.Method.ContainingType);
1081SymbolDistinguisher distinguisher = new SymbolDistinguisher(compilation, this.ContainingType, call.Method.ContainingType);
1298receiver = CheckAndConvertExtensionReceiver(receiver, method.ContainingType.ExtensionParameter, diagnostics);
1852TypeSymbol.Equals(containingMethod.ContainingType, method.ContainingType, TypeCompareKind.ConsiderEverything) &&
Binder\Binder_Operators.cs (14)
477Debug.Assert(method.ContainingType.ExtensionParameter is not null);
496leftConversion = CreateConversion(node, leftPlaceholder, conversion, isCast: false, conversionGroupOpt: null, method.ContainingType.ExtensionParameter.Type, diagnostics);
1519Debug.Assert(!(signature.Method?.ContainingType?.IsInterface ?? false));
1683NamedTypeSymbol t = (NamedTypeSymbol)signature.Method.ContainingType;
1694SourceUserDefinedOperatorSymbol.IsSelfConstrainedTypeParameter((definition = signature.Method.OriginalDefinition).ReturnType.StrippedType(), definition.ContainingType));
1839signature.Method.OriginalDefinition.ContainingType.ContainingType.GetExtensionContainers(extensions);
1855Error(diagnostics, ErrorCode.ERR_MustHaveOpTF, syntax, signature.Method, signature.Method.OriginalDefinition.ContainingType.ContainingType);
2119if (operatorMethod.ContainingType.IsInterface &&
3433Debug.Assert(method.ContainingType.ExtensionParameter is not null);
3452operandConversion = CreateConversion(node, operandPlaceholder, conversion, isCast: false, conversionGroupOpt: null, method.ContainingType.ExtensionParameter.Type, diagnostics);
3778return typeComparer.Equals(x.ContainingType, y.ContainingType) &&
3788int result = typeComparer.GetHashCode(method.ContainingType);
3807if (methodOpt?.ContainingType?.IsInterface == true && methodOpt.IsStatic)
Binder\Semantics\OverloadResolution\OverloadResolution.cs (26)
815else if (member.GetIsNewExtensionMember() && member.ContainingType is { } extension && ConstraintsHelper.RequiresChecking(extension))
906NamedTypeSymbol containingType = member.ContainingType;
1127NamedTypeSymbol memberContainingType = member.ContainingType;
1386checkOverrideContainingType && !moreDerivedOverride.ContainingType.IsDerivedFrom(member.ContainingType, TypeCompareKind.ConsiderEverything, ref useSiteInfo) ||
1420if (!member.ContainingType.IsClassType())
1439NamedTypeSymbol memberContainingType = member.ContainingType;
1442NamedTypeSymbol otherContainingType = otherMember.ContainingType;
1479|| (result.Member.GetIsNewExtensionMember() && !typeArgumentsAccessible(result.Member.ContainingType.GetMemberTypeArgumentsNoUseSiteDiagnostics(), ref useSiteInfo)))
1611if (IsLessDerivedThanAny(index: f, result.LeastOverriddenMember.ContainingType, results, ref useSiteInfo))
1636var currentType = result.LeastOverriddenMember.ContainingType;
1705var type = result.LeastOverriddenMember.ContainingType;
1727if (member.ContainingType.IsInterfaceType())
1894? memberWithPriority.ContainingType.ContainingType
1895: memberWithPriority.ContainingType;
2496if (m1.Member.ContainingType.TypeKind == TypeKind.Submission && m2.Member.ContainingType.TypeKind == TypeKind.Submission)
2596ParameterSymbol? extensionParameter = member.ContainingType.ExtensionParameter;
3893Debug.Assert(member.ContainingType.ExtensionParameter is not null);
3894hasSomeRefKinds |= member.ContainingType.ExtensionParameter.RefKind != RefKind.None;
4378? method.ContainingType.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics.Concat(method.TypeArgumentsWithAnnotations)
4384var result = property.ContainingType.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics;
4416member.ContainingType,
4435if (member.ContainingType.Arity > 0)
4437var extensionTypeArguments = MethodTypeInferrer.InferTypeArgumentsFromReceiverType(member.ContainingType, args[0], _binder.Compilation, _binder.Conversions, ref useSiteInfo);
4758return container.GetIsNewExtensionMember() && parameterType.ContainsTypeParameter(typeParameterContainer: container.ContainingType);
BoundTree\Constructors.cs (3)
62!fieldSymbol.ContainingType.IsValueType ||
254: this(syntax, constructor, ImmutableArray.Create<BoundExpression>(arguments), default(ImmutableArray<string?>), default(ImmutableArray<RefKind>), false, default(ImmutableArray<int>), default(BitVector), null, null, constructor.ContainingType)
258: this(syntax, constructor, arguments, default(ImmutableArray<string?>), default(ImmutableArray<RefKind>), false, default(ImmutableArray<int>), default(BitVector), null, null, constructor.ContainingType)
Compiler\MethodCompiler.cs (13)
248synthesizedEntryPoint = new SynthesizedEntryPointSymbol.AsyncForwardEntryPoint(compilation, entryPoint.ContainingType, entryPoint);
252moduleBeingBuilt.AddSynthesizedDefinition(entryPoint.ContainingType, synthesizedEntryPoint.GetCciAdapter());
283new TypeCompilationState(synthesizedEntryPoint.ContainingType, compilation, moduleBeingBuilt),
866if (!interfaces.Contains(synthesizedExplicitImpl.ExplicitInterfaceImplementations[0].ContainingType,
940if (methodSymbol.IsAbstract || methodSymbol.ContainingType?.IsDelegateType() == true)
1066Debug.Assert(!prependedDefaultValueTypeConstructorInitializer || methodSymbol.ContainingType.IsStructType());
1080((methodSymbol.ContainingType.IsStructType() && !methodSymbol.IsImplicitConstructor) ||
1499method.ContainingType,
1542method.ContainingType,
1560method.ContainingType,
2469Debug.Assert(!method.ContainingType.IsDelegateType());
2494if (ctorCall != null && !ctorCall.HasAnyErrors && ctorCall.Method != method && TypeSymbol.Equals(ctorCall.Method.ContainingType, method.ContainingType, TypeCompareKind.ConsiderEverything2))
FlowAnalysis\NullableWalker.cs (45)
669? method.ContainingType.GetMembersUnordered().SelectManyAsArray(
679foreach (var member in method.ContainingType.GetMembersUnordered())
694if (chainedConstructorEnforcesRequiredMembers && !constructorEnforcesRequiredMembers && method.ContainingType.BaseTypeNoUseSiteDiagnostics is { } baseType)
914&& (!method.ContainingType.IsValueType
918return membersToBeInitialized(method.ContainingType, includeAllMembers: true, includeCurrentTypeRequiredMembers, includeBaseRequiredMembers);
923return membersToBeInitialized(method.ContainingType, includeAllMembers: method.IncludeFieldInitializersInBody(), includeCurrentTypeRequiredMembers, includeBaseRequiredMembers);
1019foreach (var member in property.ContainingType.GetMembers(notNullMemberName))
1062foreach (var member in method.ContainingType.GetMembers(memberName))
1098enforceMemberNotNullWhenIfAffected(returnStatement.Syntax, sense: true, members: method.ContainingType.GetMembers(memberName), state: pendingReturn.StateWhenTrue, otherState: pendingReturn.StateWhenFalse);
1103enforceMemberNotNullWhenIfAffected(returnStatement.Syntax, sense: false, members: method.ContainingType.GetMembers(memberName), state: pendingReturn.StateWhenFalse, otherState: pendingReturn.StateWhenTrue);
1129foreach (var member in method.ContainingType.GetMembers(memberName))
1182var type = method.ContainingType;
1501&& method.ContainingType is SourceMemberContainerTypeSymbol containingType)
2255if ((constructor.IsStatic && containingSlot == 0 && constructor.ContainingType.Equals(symbol.ContainingType))
2715TypeSymbol possibleBase = possibleMember.ContainingType;
3767(FieldSymbol { ContainingType: { IsTupleType: true }, TupleElementIndex: var oi } originalField, FieldSymbol { ContainingType: { IsTupleType: true }, TupleElementIndex: var ui } updatedField) =>
4195var containingType = constructor?.ContainingType;
5386TypeSymbol methodContainer = method.ContainingType;
5395else if (method.ContainingType.Arity != 0)
5397NamedTypeSymbol extension = method.OriginalDefinition.ContainingType;
5759var containingType = this._symbol?.ContainingType;
6511Debug.Assert(node.Method.ContainingType.ExtensionParameter is not null);
6512annotations = node.Method.ContainingType.ExtensionParameter.FlowAnalysisAnnotations;
6663ParameterSymbol? extensionParameter = method.ContainingType.ExtensionParameter;
6698ParameterSymbol? extensionParameter = method.ContainingType.ExtensionParameter;
6787var wellKnownType = wellKnownMethod.ContainingType;
6808if (implementationMethod.ContainingType.IsInterface)
6839while (!baseType.Equals(implementationMethod.ContainingType) && method is object)
6841if (baseType.Equals(method.ContainingType))
6855if (method is object && baseType.Equals(method.ContainingType))
6980method.ContainingType.IsReferenceType)
7278if (member.ContainingType is { } extension && ConstraintsHelper.RequiresChecking(extension))
7602var type = method.ContainingType;
8319definition.ContainingType,
8690var symbolContainer = symbol.ContainingType;
8702Debug.Assert(symbol.ContainingType.IsDefinition);
9775var newExtensionFormOffset = parameterOpt?.ContainingType.IsExtension is true ? 1 : 0;
10349ParameterSymbol? receiverParameter = isNewExtensionMethod ? method.ContainingType.ExtensionParameter : method.Parameters[0];
10738var receiverParameter = isNewExtension ? deconstructMethod.ContainingType.ExtensionParameter : deconstructMethod.Parameters[0];
11342var extensionParameter = property.ContainingType.ExtensionParameter;
11518if ((object)getMethod != null && getMethod.ContainingType.SpecialType == SpecialType.System_Nullable_T)
12019else if (method.ContainingType.Arity != 0)
12021NamedTypeSymbol extension = method.OriginalDefinition.ContainingType;
Lowering\DiagnosticsPass_ExpressionTrees.cs (2)
278Binder.ReportDiagnosticsIfObsolete(_diagnostics, node.EventSymbol.AssociatedField, node.Syntax, hasBaseReceiver, _containingSymbol, _containingSymbol.ContainingType, BinderFlags.None);
292Binder.ReportDiagnosticsIfObsolete(_diagnostics, node.Event, ((AssignmentExpressionSyntax)node.Syntax).Left, hasBaseReceiver, _containingSymbol, _containingSymbol.ContainingType, BinderFlags.None);
Lowering\SyntheticBoundNodeFactory.cs (9)
76_currentType = value.ContainingType;
104: this(topLevelMethod, topLevelMethod.ContainingType, node, compilationState, diagnostics, instrumentationState)
134Debug.Assert(TopLevelMethod is null || TypeSymbol.Equals(TopLevelMethod.ContainingType, CurrentType, TypeCompareKind.ConsiderEverything2));
143TypeSymbol.Equals(CurrentFunction.ContainingType, CurrentType, TypeCompareKind.ConsiderEverything2));
774constructor.ContainingType)
1320GetMethodFromHandleMethod(ctor.ContainingType, constructorInfo),
1419if (!method.ContainingType.IsValueType || !Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.MayUseCallForStructMethod(method))
1427GetMethodFromHandleMethod(method.ContainingType, systemReflectionMethodInfo),
1443GetFieldFromHandleMethod(field.ContainingType),
Symbols\Source\SourceMethodSymbolWithAttributes.cs (14)
538AttributeData.DecodeMethodImplAttribute<MethodWellKnownAttributeData, AttributeSyntax, CSharpAttributeData, AttributeLocation>(ref arguments, MessageProvider.Instance, this.ContainingType);
599CSharpAttributeData.DecodeMemberNotNullAttribute<MethodWellKnownAttributeData>(ContainingType, ref arguments);
604CSharpAttributeData.DecodeMemberNotNullWhenAttribute<MethodWellKnownAttributeData>(ContainingType, ref arguments);
626if (ContainingType.IsInterface || IsExplicitInterfaceImplementation)
734else if (this.ContainingType.IsInterfaceType())
854if (isAnyNestedMethodGeneric || ContainingType?.IsGenericType == true)
964Debug.Assert(ContainingType is object);
982if (IsGenericMethod || ContainingType.IsGenericType)
1362if (!this.GetIsNewExtensionMember() && ContainingType.IsGenericType)
1501diagnostics.Add(ErrorCode.ERR_ComImportWithImpl, this.GetFirstLocation(), this, ContainingType);
1513&& !this.ContainingType.IsComImport)
1569for (NamedTypeSymbol curr = this.ContainingType; (object)curr != null; curr = curr.ContainingType)
1661return this.ContainingType.IsInterface &&
1753if (this.ContainingType.IsComImport && this.MethodKind == MethodKind.Constructor)