internal static void Analyze(CSharpCompilation compilation, MethodSymbol method, BoundNode node, DiagnosticBag diagnostics) { Debug.Assert(method.MethodKind == MethodKind.Constructor); if (compilation.LanguageVersion < MessageID.IDS_FeatureNullableReferenceTypes.RequiredVersion()) { return; } if (HasThisConstructorInitializer(method)) { return; } var walker = new UnassignedFieldsWalker(compilation, method, node, diagnostics); try { bool badRegion = false; walker.Analyze(ref badRegion, diagnostics: null); } finally { walker.Free(); } }
internal static void Analyze(CSharpCompilation compilation, MethodSymbol method, BoundNode node, DiagnosticBag diagnostics) { Debug.Assert(method.MethodKind == MethodKind.Constructor); if (method.NonNullTypes != true) { return; } if (HasThisConstructorInitializer(method)) { return; } var walker = new UnassignedFieldsWalker(compilation, method, node, diagnostics); try { bool badRegion = false; walker.Analyze(ref badRegion, diagnostics: null); } finally { walker.Free(); } }
internal static void ReportUninitializedNonNullableReferenceTypeFields( UnassignedFieldsWalker walkerOpt, int thisSlot, bool isStatic, ImmutableArray <Symbol> members, Func <UnassignedFieldsWalker, int, Symbol, bool> getIsAssigned, Func <UnassignedFieldsWalker, Symbol, Symbol> getSymbolForLocation, DiagnosticBag diagnostics) { foreach (var member in members) { if (member.IsStatic != isStatic) { continue; } TypeWithAnnotations fieldType; FieldSymbol field; switch (member) { case FieldSymbol f: fieldType = f.TypeWithAnnotations; field = f; break; case EventSymbol e: fieldType = e.TypeWithAnnotations; field = e.AssociatedField; if (field is null) { continue; } break; default: continue; } if (field.IsConst) { continue; } if (fieldType.Type.IsValueType || fieldType.Type.IsErrorType()) { continue; } if (!fieldType.NullableAnnotation.IsNotAnnotated() && !fieldType.Type.IsTypeParameterDisallowingAnnotation()) { continue; } if (getIsAssigned(walkerOpt, thisSlot, field)) { continue; } var symbol = member switch { FieldSymbol { AssociatedSymbol : PropertySymbol p } => p,