Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add Span.TryWrite, StringBuilder.Append, and String.Create interpolated strings support#51653

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from1 commit
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
NextNext commit
Add Span.TryWrite, StringBuilder.Append, and String.Create interpolat…
…ed strings support
  • Loading branch information
@stephentoub
stephentoub committedJul 13, 2021
commit3a8a13c9e7b67dfceee4dde2ec1787f046ac84f2
21 changes: 21 additions & 0 deletionssrc/libraries/System.Memory/ref/System.Memory.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -143,6 +143,27 @@ public static void Sort<TKey, TValue, TComparer>(this System.Span<TKey> keys, Sy
public static System.ReadOnlySpan<T> Trim<T>(this System.ReadOnlySpan<T> span, T trimElement) where T : System.IEquatable<T> { throw null; }
public static System.Span<T> Trim<T>(this System.Span<T> span, System.ReadOnlySpan<T> trimElements) where T : System.IEquatable<T> { throw null; }
public static System.Span<T> Trim<T>(this System.Span<T> span, T trimElement) where T : System.IEquatable<T> { throw null; }
public static bool TryWrite(this System.Span<char> destination, [System.Runtime.CompilerServices.InterpolatedStringHandlerArgumentAttribute("destination")] ref System.MemoryExtensions.TryWriteInterpolatedStringHandler handler, out int charsWritten) { throw null; }
public static bool TryWrite(this System.Span<char> destination, IFormatProvider? provider, [System.Runtime.CompilerServices.InterpolatedStringHandlerArgumentAttribute("destination", "provider")] ref System.MemoryExtensions.TryWriteInterpolatedStringHandler handler, out int charsWritten) { throw null; }
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[System.Runtime.CompilerServices.InterpolatedStringHandlerAttribute]
public ref struct TryWriteInterpolatedStringHandler
{
private readonly object _dummy;
private readonly int _dummyPrimitive;
public TryWriteInterpolatedStringHandler(int literalLength, int formattedCount, System.Span<char> destination, out bool success) { throw null; }
public TryWriteInterpolatedStringHandler(int literalLength, int formattedCount, System.Span<char> destination, IFormatProvider? provider, out bool success) { throw null; }
public bool AppendLiteral(string value) { throw null; }
public bool AppendFormatted(System.ReadOnlySpan<char> value) { throw null; }
public bool AppendFormatted(System.ReadOnlySpan<char> value, int alignment = 0, string? format = null) { throw null; }
public bool AppendFormatted<T>(T value) { throw null; }
public bool AppendFormatted<T>(T value, string? format) { throw null; }
public bool AppendFormatted<T>(T value, int alignment) { throw null; }
public bool AppendFormatted<T>(T value, int alignment, string? format) { throw null; }
public bool AppendFormatted(object? value, int alignment = 0, string? format = null) { throw null; }
public bool AppendFormatted(string? value) { throw null; }
public bool AppendFormatted(string? value, int alignment = 0, string? format = null) { throw null; }
}
}
public readonly partial struct SequencePosition : System.IEquatable<System.SequencePosition>
{
Expand Down
728 changes: 728 additions & 0 deletionssrc/libraries/System.Memory/tests/Span/TryWrite.cs
View file
Open in desktop

Large diffs are not rendered by default.

View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -112,6 +112,7 @@
<Compile Include="Span\StartsWith.T.cs" />
<Compile Include="Span\ToArray.cs" />
<Compile Include="Span\ToString.cs" />
<Compile Include="Span\TryWrite.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="ReadOnlyBuffer\ReadOnlySequenceTests.Common.char.cs" />
Expand Down
View file
Open in desktop

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletionssrc/libraries/System.Private.CoreLib/src/System/String.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -391,6 +391,21 @@ public static string Create<TState>(int length, TState state, SpanAction<char, T
return result;
}

/// <summary>Creates a new string by using the specified provider to control the formatting of the specified interpolated string.</summary>
/// <param name="provider">An object that supplies culture-specific formatting information.</param>
/// <param name="handler">The interpolated string.</param>
/// <returns>The string that results for formatting the interpolated string using the specified format provider.</returns>
public static string Create(IFormatProvider? provider, [InterpolatedStringHandlerArgument("provider")] ref DefaultInterpolatedStringHandler handler) =>
handler.ToStringAndClear();

/// <summary>Creates a new string by using the specified provider to control the formatting of the specified interpolated string.</summary>
/// <param name="provider">An object that supplies culture-specific formatting information.</param>
/// <param name="initialBuffer">The initial buffer that may be used as temporary space as part of the formatting operation. The contents of this buffer may be overwritten.</param>
/// <param name="handler">The interpolated string.</param>
/// <returns>The string that results for formatting the interpolated string using the specified format provider.</returns>
public static string Create(IFormatProvider? provider, Span<char> initialBuffer, [InterpolatedStringHandlerArgument("provider", "initialBuffer")] ref DefaultInterpolatedStringHandler handler) =>
handler.ToStringAndClear();

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator ReadOnlySpan<char>(string? value) =>
value != null ? new ReadOnlySpan<char>(ref value.GetRawStringData(), value.Length) : default;
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp