[API Proposal]: String-to-String Base64 Encode/Decode
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start by reviewing the proposed APIs for System.Convert, System.Buffers.Text.Base64, and Base64Url, along with the existing Base64 APIs they extend. The issue does not name files or tests; the first step is to determine whether the proposed signatures and behavior fit the project’s API conventions. Done means the proposal has a clear design decision, including the Encoding parameters.
索引モデルが issue の本文から書いたものです。
説明
Background and Motivation
Today, .NET's Base64 APIs have a gap: there is no direct way to encode a string to a Base64 string, or decode a Base64 string back to a string. Every existing method either accepts byte[] / ReadOnlySpan<byte> as input (encode side) or returns byte[] (decode side).
This pattern is extremely common across the .NET ecosystem. It appears in CI/CD tooling, configuration loaders, certificate handling, token encoding, and countless other packages. In many cases the Base64-encoded values are stored as strings in configuration files, databases, or API responses and need to be decoded back to strings when consumed later.
var certPem = Encoding.UTF8.GetString(Convert.FromBase64String(configuration.ClientCertificateData));
var releaseBuildBase64 = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(releaseBuild));
This is verbose, does not have easy discoverability and allocates an intermediate byte[] that could be avoided internally.
Proposed API
All methods accept ReadOnlySpan<char> rather than string — callers can pass a string directly thanks to the implicit conversion.
namespace System;
public static partial class Convert
{
public static string ToBase64String(ReadOnlySpan<char> source, Encoding encoding);
public static string ToBase64String(ReadOnlySpan<char> source, Encoding encoding, Base64FormattingOptions options);
}
namespace System.Buffers.Text;
public static partial class Base64
{
public static string EncodeToString(ReadOnlySpan<char> source, Encoding encoding);
public static string DecodeToString(ReadOnlySpan<char> source, Encoding encoding);
}
public static partial class Base64Url
{
public static string EncodeToString(ReadOnlySpan<char> source, Encoding encoding);
public static string DecodeToString(ReadOnlySpan<char> source, Encoding encoding);
}
API Usage
// Encode a connection string for safe storage in a config file
string encoded = Convert.ToBase64String("Server=prod;Database=App;User=admin;", Encoding.UTF8);
// Decode it back when reading the config
string connectionString = Convert.FromBase64ToString(encoded, Encoding.UTF8);
Edit: Added Encoding parameters
- 主要言語
- C#
- スター
- 18.4k
- フォーク
- 5.8k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 588
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dotnet/runtime のほかの issue
-
area-System.IO untriaged
難易度 2/5 半日 初心者へのやさしさ 72/100
dotnet/runtime#136802 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[wasi] .NET 10: WasmEnableSIMD with AOT fails because WasiApp.targets has -msimd128 commented outオープンarea-Build-mono untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
area-System.ComponentModel untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
dotnet/runtime#136608 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
MemoryMappedFile (Windows): failed MEM_COMMIT is ignored, accessor over reserved memory crashes the process対応中かも @RutulPatel8 が 1 日前に担当しました。 オープンarea-System.IO bug untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
dotnet/runtime#136599 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area-System.IO untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
dotnet/runtime#136577 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
RadicalCSG/com.chisel#192 ·
メンテナーはふだん 1 日以内に返信
-
area-testing p2-post-1.0 technical-debt
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
Bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
RazorConsole/RazorConsole#447 ·
メンテナーはふだん 1 日以内に返信
-
CloudEventsMiddleware decodes JSON string data for `+json` content types対応中かも @RaphaelFakhri が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
dapr/dotnet-sdk#1964 ·
メンテナーはふだん 1 日以内に返信
-
bug P3
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信