Repository: dotnet/roslyn
File: src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs (C#)

Code before:
        /// </summary>
        internal static NamedTypeSymbol GetWellKnownType(CSharpCompilation compilation, WellKnownType type, BindingDiagnosticBag diagnostics, SyntaxNode node)
        {
            return GetWellKnownType(compilation, type, diagnostics, node.Location);
        }

#nullable enable
        internal static NamedTypeSymbol GetWellKnownType(CSharpCompilation compilation, WellKnownType type, BindingDiagnosticBag diagnostics, Location location)
        {
            NamedTypeSymbol typeSymbol = compilation.GetWellKnownType(type);
            Debug.Assert((object)typeSymbol != null, "Expect an error type if well-known type isn't found");
            ReportUseSite(typeSymbol, diagnostics, location);
            return typeSymbol;
        }

        internal static bool TryGetWellKnownType(CSharpCompilation compilation, WellKnownType type, BindingDiagnosticBag diagnostics, Location location, [NotNullWhen(true)] out NamedTypeSymbol? typeSymbol)
        {
            typeSymbol = compilation.GetWellKnownType(type);
            Debug.Assert((object)typeSymbol != null, "Expect an error type if well-known type isn't found");
            if (typeSymbol.GetUseSiteInfo().DiagnosticInfo?.Severity == DiagnosticSeverity.Error)
            {
                typeSymbol = null;
                return false;
            }

            ReportUseSite(typeSymbol, diagnostics, location);
            return true;
        }
#nullable disable

        /// <summary>
        /// This is a layer on top of the Compilation version that generates a diagnostic if the well-known
        /// type isn't found.
        /// </summary>
        internal NamedTypeSymbol GetWellKnownType(WellKnownType type, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
        {
            NamedTypeSymbol typeSymbol = this.Compilation.GetWellKnownType(type);
            Debug.Assert((object)typeSymbol != null, "Expect an error type if well-known type isn't found");
            typeSymbol.AddUseSiteInfo(ref useSiteInfo);
            return typeSymbol;
        }

        internal Symbol GetWellKnownTypeMember(WellKnownMember member, BindingDiagnosticBag diagnostics, Location location = null, SyntaxNode syntax = null, bool isOptional = false)
        {
            return GetWellKnownTypeMember(Compilation, member, diagnostics, location, syntax, isOptional);
        }

        /// <summary>
        /// Retrieves a well-known type member and reports diagnostics.
        /// </summary>
        /// <returns>Null if the symbol is missing.</returns>

Review comment (suggestion):
>ReportUseSite(typeSymbol, diagnostics, location); [](http://example.com/codeflow?start=12&length=49)

The original suggestion was to mimic behavior of ``internal static Symbol GetWellKnownTypeMember(CSharpCompilation compilation, WellKnownMember member, out UseSiteInfo<AssemblySymbol> useSiteInfo, bool isOptional = false)``` and ignore warnings. #Closed

Code after:
        /// </summary>
        internal static NamedTypeSymbol GetWellKnownType(CSharpCompilation compilation, WellKnownType type, BindingDiagnosticBag diagnostics, SyntaxNode node)
        {
            return GetWellKnownType(compilation, type, diagnostics, node.Location);
        }

#nullable enable
        internal static NamedTypeSymbol GetWellKnownType(CSharpCompilation compilation, WellKnownType type, BindingDiagnosticBag diagnostics, Location location)
        {
            NamedTypeSymbol typeSymbol = compilation.GetWellKnownType(type);
            Debug.Assert((object)typeSymbol != null, "Expect an error type if well-known type isn't found");
            ReportUseSite(typeSymbol, diagnostics, location);
            return typeSymbol;
        }

        internal static bool TryGetOptionalWellKnownType(CSharpCompilation compilation, WellKnownType type, BindingDiagnosticBag diagnostics, Location location, [NotNullWhen(true)] out NamedTypeSymbol? typeSymbol)
        {
            typeSymbol = compilation.GetWellKnownType(type);
            Debug.Assert((object)typeSymbol != null, "Expect an error type if well-known type isn't found");
            var useSiteInfo = typeSymbol.GetUseSiteInfo();
            if (useSiteInfo.DiagnosticInfo?.Severity == DiagnosticSeverity.Error)
            {
                typeSymbol = null;
                return false;
            }

            // Ignore warnings
            useSiteInfo = new UseSiteInfo<AssemblySymbol>(diagnosticInfo: null, useSiteInfo.PrimaryDependency, useSiteInfo.SecondaryDependencies);
            diagnostics.Add(useSiteInfo, location);
            return true;
        }
#nullable disable

        /// <summary>
        /// This is a layer on top of the Compilation version that generates a diagnostic if the well-known
        /// type isn't found.
        /// </summary>
        internal NamedTypeSymbol GetWellKnownType(WellKnownType type, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
        {
            NamedTypeSymbol typeSymbol = this.Compilation.GetWellKnownType(type);
            Debug.Assert((object)typeSymbol != null, "Expect an error type if well-known type isn't found");
            typeSymbol.AddUseSiteInfo(ref useSiteInfo);
            return typeSymbol;
        }

        internal Symbol GetWellKnownTypeMember(WellKnownMember member, BindingDiagnosticBag diagnostics, Location location = null, SyntaxNode syntax = null, bool isOptional = false)
        {
            return GetWellKnownTypeMember(Compilation, member, diagnostics, location, syntax, isOptional);
        }

        /// <summary>