Skip to content

EnsureValidDataType should reject whitespaces in DataTypeAttribute.CustomDataType property #15690

@sparraguerra

Description

@sparraguerra

Method EnsureValidDataType() should not raise an exception when the property CustomDataType is a WhiteSpace?

This code:

/// <summary>
///  Throws an exception if this attribute is not correctly formed
/// </summary>
/// <exception cref="InvalidOperationException"> is thrown if the current attribute is ill-formed.</exception>
private void EnsureValidDataType()
{
    if (DataType == DataType.Custom && string.IsNullOrEmpty(CustomDataType))
    {
         throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
               SR.DataTypeAttribute_EmptyDataTypeString));
     }
}

Should be?

/// <summary>
///  Throws an exception if this attribute is not correctly formed
/// </summary>
/// <exception cref="InvalidOperationException"> is thrown if the current attribute is ill-formed.</exception>
private void EnsureValidDataType()
{
    if (DataType == DataType.Custom && string.IsNullOrWhiteSpace(CustomDataType))
    {
         throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
               SR.DataTypeAttribute_EmptyDataTypeString));
     }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions