private ConstantValue DecodeDefaultParameterValueAttribute(AttributeDescription description, CSharpAttributeData attribute, AttributeSyntax node, bool diagnose, DiagnosticBag diagnosticsOpt) { Debug.Assert(!attribute.HasErrors); if (description.Equals(AttributeDescription.DefaultParameterValueAttribute)) { return(DecodeDefaultParameterValueAttribute(attribute, node, diagnose, diagnosticsOpt)); } else if (description.Equals(AttributeDescription.DecimalConstantAttribute)) { return(attribute.DecodeDecimalConstantValue()); } else { Debug.Assert(description.Equals(AttributeDescription.DateTimeConstantAttribute)); return(attribute.DecodeDateTimeConstantValue()); } }
private ConstantValue DecodeDefaultParameterValueAttribute(AttributeDescription description, CSharpAttributeData attribute, AttributeSyntax node, bool diagnose, DiagnosticBag diagnosticsOpt) { Debug.Assert(!attribute.HasErrors); if (description.Equals(AttributeDescription.DefaultParameterValueAttribute)) { return DecodeDefaultParameterValueAttribute(attribute, node, diagnose, diagnosticsOpt); } else if (description.Equals(AttributeDescription.DecimalConstantAttribute)) { return attribute.DecodeDecimalConstantValue(); } else { Debug.Assert(description.Equals(AttributeDescription.DateTimeConstantAttribute)); return attribute.DecodeDateTimeConstantValue(); } }
private CSharpAttributeData EarlyDecodeAttributeForDefaultParameterValue(AttributeDescription description, ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments) { Debug.Assert(description.Equals(AttributeDescription.DefaultParameterValueAttribute) || description.Equals(AttributeDescription.DecimalConstantAttribute) || description.Equals(AttributeDescription.DateTimeConstantAttribute)); bool hasAnyDiagnostics; var attribute = arguments.Binder.GetAttribute(arguments.AttributeSyntax, arguments.AttributeType, out hasAnyDiagnostics); ConstantValue value; if (attribute.HasErrors) { value = ConstantValue.Bad; hasAnyDiagnostics = true; } else { value = DecodeDefaultParameterValueAttribute(description, attribute, arguments.AttributeSyntax, diagnose: false, diagnosticsOpt: null); } var paramData = arguments.GetOrCreateData<ParameterEarlyWellKnownAttributeData>(); if (paramData.DefaultParameterValue == ConstantValue.Unset) { paramData.DefaultParameterValue = value; } return !hasAnyDiagnostics ? attribute : null; }