private void ValidateCallerLineNumberAttribute(AttributeSyntax node, DiagnosticBag diagnostics) { CSharpCompilation compilation = this.DeclaringCompilation; HashSet <DiagnosticInfo> useSiteDiagnostics = null; if (!IsValidCallerInfoContext(node)) { // CS4024: The CallerLineNumberAttribute applied to parameter '{0}' will have no effect because it applies to a // member that is used in contexts that do not allow optional arguments diagnostics.Add(ErrorCode.WRN_CallerLineNumberParamForUnconsumedLocation, node.Name.Location, CSharpSyntaxNode.Identifier.ValueText); } else if (!compilation.Conversions.HasCallerLineNumberConversion(Type, ref useSiteDiagnostics)) { // CS4017: CallerLineNumberAttribute cannot be applied because there are no standard conversions from type '{0}' to type '{1}' TypeSymbol intType = compilation.GetSpecialType(SpecialType.System_Int32); diagnostics.Add(ErrorCode.ERR_NoConversionForCallerLineNumberParam, node.Name.Location, intType, Type); } else if (!HasExplicitDefaultValue && !ContainingSymbol.IsPartialImplementation()) // attribute applied to parameter without default { // Unconsumed location checks happen first, so we require a default value. // CS4020: The CallerLineNumberAttribute may only be applied to parameters with default values diagnostics.Add(ErrorCode.ERR_BadCallerLineNumberParamWithoutDefaultValue, node.Name.Location); } diagnostics.Add(node.Name.Location, useSiteDiagnostics); }