From 86b48d7c6f081c12dcc9c048fb53de1b78c9966f Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Sun, 9 Apr 2023 09:58:52 -0400 Subject: [PATCH] Fix IUtf8SpanFormattable.TryFormat argument name (#84535) The approved parameter name was `utf8Destination` rather than just `destination`. --- .../src/System/IUtf8SpanFormattable.cs | 10 +++++----- src/libraries/System.Runtime/ref/System.Runtime.cs | 2 +- .../tests/System/Text/Unicode/Utf8Tests.TryWrite.cs | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/IUtf8SpanFormattable.cs b/src/libraries/System.Private.CoreLib/src/System/IUtf8SpanFormattable.cs index 6815b84f0aaea..7fa4dd9c30151 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IUtf8SpanFormattable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IUtf8SpanFormattable.cs @@ -7,15 +7,15 @@ namespace System public interface IUtf8SpanFormattable { /// Tries to format the value of the current instance as UTF8 into the provided span of bytes. - /// When this method returns, this instance's value formatted as a span of bytes. - /// When this method returns, the number of bytes that were written in . - /// A span containing the characters that represent a standard or custom format string that defines the acceptable format for . - /// An optional object that supplies culture-specific formatting information for . + /// When this method returns, this instance's value formatted as a span of bytes. + /// When this method returns, the number of bytes that were written in . + /// A span containing the characters that represent a standard or custom format string that defines the acceptable format for . + /// An optional object that supplies culture-specific formatting information for . /// if the formatting was successful; otherwise, . /// /// An implementation of this interface should produce the same string of characters as an implementation of or /// on the same type. TryFormat should return false only if there is not enough space in the destination buffer; any other failures should throw an exception. /// - bool TryFormat(Span destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider); + bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider); } } diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index d6c76849d8bb2..c21fc44daf0ca 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -3871,7 +3871,7 @@ public partial interface ISpanParsable : System.IParsable where TS } public partial interface IUtf8SpanFormattable { - bool TryFormat(System.Span destination, out int bytesWritten, System.ReadOnlySpan format, System.IFormatProvider? provider); + bool TryFormat(System.Span utf8Destination, out int bytesWritten, System.ReadOnlySpan format, System.IFormatProvider? provider); } public partial class Lazy<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]T> { diff --git a/src/libraries/System.Runtime/tests/System/Text/Unicode/Utf8Tests.TryWrite.cs b/src/libraries/System.Runtime/tests/System/Text/Unicode/Utf8Tests.TryWrite.cs index c9cdaf3d0ef87..8ce9e7d76e097 100644 --- a/src/libraries/System.Runtime/tests/System/Text/Unicode/Utf8Tests.TryWrite.cs +++ b/src/libraries/System.Runtime/tests/System/Text/Unicode/Utf8Tests.TryWrite.cs @@ -584,14 +584,14 @@ public Utf8SpanFormattableInt32Wrapper(int value) _value = value; } - public bool TryFormat(Span destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider provider) + public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider provider) { ToStringState.LastFormat = format.ToString(); ToStringState.LastProvider = provider; ToStringState.ToStringMode = ToStringMode.ISpanFormattableTryFormat; ReadOnlySpan src = Encoding.UTF8.GetBytes(_value.ToString(format.ToString(), provider)).AsSpan(); - if (src.TryCopyTo(destination)) + if (src.TryCopyTo(utf8Destination)) { bytesWritten = src.Length; return true;