Skip to content

Add more StringSyntaxAttrbute syntaxes #44663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/Components/Components/src/BindConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ private static string FormatDecimalValueCore(decimal value, CultureInfo? culture
/// </param>
/// <returns>The formatted value.</returns>
[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]
public static string FormatValue(DateTime value, string format, CultureInfo? culture = null) => FormatDateTimeValueCore(value, format, culture);
public static string FormatValue(DateTime value, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string format, CultureInfo? culture = null) => FormatDateTimeValueCore(value, format, culture);

private static string FormatDateTimeValueCore(DateTime value, string? format, CultureInfo? culture)
{
Expand Down Expand Up @@ -373,7 +373,7 @@ private static string FormatDateTimeValueCore(DateTime value, CultureInfo? cultu
/// </param>
/// <returns>The formatted value.</returns>
[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]
public static string? FormatValue(DateTime? value, string? format, CultureInfo? culture = null) => FormatNullableDateTimeValueCore(value, format, culture);
public static string? FormatValue(DateTime? value, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string? format, CultureInfo? culture = null) => FormatNullableDateTimeValueCore(value, format, culture);

private static string? FormatNullableDateTimeValueCore(DateTime? value, string? format, CultureInfo? culture)
{
Expand Down Expand Up @@ -507,7 +507,7 @@ private static string FormatDateTimeOffsetValueCore(DateTimeOffset value, Cultur
/// </param>
/// <returns>The formatted value.</returns>
[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]
public static string FormatValue(DateOnly value, string format, CultureInfo? culture = null) => FormatDateOnlyValueCore(value, format, culture);
public static string FormatValue(DateOnly value, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string format, CultureInfo? culture = null) => FormatDateOnlyValueCore(value, format, culture);

private static string FormatDateOnlyValueCore(DateOnly value, string? format, CultureInfo? culture)
{
Expand Down Expand Up @@ -546,7 +546,7 @@ private static string FormatDateOnlyValueCore(DateOnly value, CultureInfo? cultu
/// </param>
/// <returns>The formatted value.</returns>
[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]
public static string? FormatValue(DateOnly? value, string format, CultureInfo? culture = null) => FormatNullableDateOnlyValueCore(value, format, culture);
public static string? FormatValue(DateOnly? value, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string format, CultureInfo? culture = null) => FormatNullableDateOnlyValueCore(value, format, culture);

private static string? FormatNullableDateOnlyValueCore(DateOnly? value, string? format, CultureInfo? culture)
{
Expand Down Expand Up @@ -595,7 +595,7 @@ private static string FormatDateOnlyValueCore(DateOnly value, CultureInfo? cultu
/// </param>
/// <returns>The formatted value.</returns>
[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]
public static string FormatValue(TimeOnly value, string format, CultureInfo? culture = null) => FormatTimeOnlyValueCore(value, format, culture);
public static string FormatValue(TimeOnly value, [StringSyntax(StringSyntaxAttribute.TimeOnlyFormat)] string format, CultureInfo? culture = null) => FormatTimeOnlyValueCore(value, format, culture);

private static string FormatTimeOnlyValueCore(TimeOnly value, string? format, CultureInfo? culture)
{
Expand Down Expand Up @@ -634,7 +634,7 @@ private static string FormatTimeOnlyValueCore(TimeOnly value, CultureInfo? cultu
/// </param>
/// <returns>The formatted value.</returns>
[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Required to maintain compatibility")]
public static string? FormatValue(TimeOnly? value, string format, CultureInfo? culture = null) => FormatNullableTimeOnlyValueCore(value, format, culture);
public static string? FormatValue(TimeOnly? value, [StringSyntax(StringSyntaxAttribute.TimeOnlyFormat)] string format, CultureInfo? culture = null) => FormatNullableTimeOnlyValueCore(value, format, culture);

private static string? FormatNullableTimeOnlyValueCore(TimeOnly? value, string? format, CultureInfo? culture)
{
Expand Down Expand Up @@ -1183,7 +1183,7 @@ public static bool TryConvertToDateTime(object? obj, CultureInfo? culture, out D
/// <param name="format">The format string to use in conversion.</param>
/// <param name="value">The converted value.</param>
/// <returns><c>true</c> if conversion is successful, otherwise <c>false</c>.</returns>
public static bool TryConvertToDateTime(object? obj, CultureInfo? culture, string format, out DateTime value)
public static bool TryConvertToDateTime(object? obj, CultureInfo? culture, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string format, out DateTime value)
{
return ConvertToDateTimeCore(obj, culture, format, out value);
}
Expand All @@ -1208,7 +1208,7 @@ public static bool TryConvertToNullableDateTime(object? obj, CultureInfo? cultur
/// <param name="format">The format string to use in conversion.</param>
/// <param name="value">The converted value.</param>
/// <returns><c>true</c> if conversion is successful, otherwise <c>false</c>.</returns>
public static bool TryConvertToNullableDateTime(object? obj, CultureInfo? culture, string format, out DateTime? value)
public static bool TryConvertToNullableDateTime(object? obj, CultureInfo? culture, [StringSyntax(StringSyntaxAttribute.DateTimeFormat)] string format, out DateTime? value)
{
return ConvertToNullableDateTimeCore(obj, culture, format, out value);
}
Expand Down Expand Up @@ -1409,7 +1409,7 @@ public static bool TryConvertToDateOnly(object? obj, CultureInfo? culture, out D
/// <param name="format">The format string to use in conversion.</param>
/// <param name="value">The converted value.</param>
/// <returns><c>true</c> if conversion is successful, otherwise <c>false</c>.</returns>
public static bool TryConvertToDateOnly(object? obj, CultureInfo? culture, string format, out DateOnly value)
public static bool TryConvertToDateOnly(object? obj, CultureInfo? culture, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string format, out DateOnly value)
{
return ConvertToDateOnlyCore(obj, culture, format, out value);
}
Expand All @@ -1434,7 +1434,7 @@ public static bool TryConvertToNullableDateOnly(object? obj, CultureInfo? cultur
/// <param name="format">The format string to use in conversion.</param>
/// <param name="value">The converted value.</param>
/// <returns><c>true</c> if conversion is successful, otherwise <c>false</c>.</returns>
public static bool TryConvertToNullableDateOnly(object? obj, CultureInfo? culture, string format, out DateOnly? value)
public static bool TryConvertToNullableDateOnly(object? obj, CultureInfo? culture, [StringSyntax(StringSyntaxAttribute.DateOnlyFormat)] string format, out DateOnly? value)
{
return ConvertToNullableDateOnlyCore(obj, culture, format, out value);
}
Expand Down Expand Up @@ -1500,7 +1500,7 @@ public static bool TryConvertToTimeOnly(object? obj, CultureInfo? culture, out T
/// <param name="format">The format string to use in conversion.</param>
/// <param name="value">The converted value.</param>
/// <returns><c>true</c> if conversion is successful, otherwise <c>false</c>.</returns>
public static bool TryConvertToTimeOnly(object? obj, CultureInfo? culture, string format, out TimeOnly value)
public static bool TryConvertToTimeOnly(object? obj, CultureInfo? culture, [StringSyntax(StringSyntaxAttribute.TimeOnlyFormat)] string format, out TimeOnly value)
{
return ConvertToTimeOnlyCore(obj, culture, format, out value);
}
Expand All @@ -1525,7 +1525,7 @@ public static bool TryConvertToNullableTimeOnly(object? obj, CultureInfo? cultur
/// <param name="format">The format string to use in conversion.</param>
/// <param name="value">The converted value.</param>
/// <returns><c>true</c> if conversion is successful, otherwise <c>false</c>.</returns>
public static bool TryConvertToNullableTimeOnly(object? obj, CultureInfo? culture, string format, out TimeOnly? value)
public static bool TryConvertToNullableTimeOnly(object? obj, CultureInfo? culture, [StringSyntax(StringSyntaxAttribute.TimeOnlyFormat)] string format, out TimeOnly? value)
{
return ConvertToNullableTimeOnlyCore(obj, culture, format, out value);
}
Expand Down