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

Appearance settings

Add Uri.UriSchemeData constant - #123147

#123147
Merged
stephentoub merged 3 commits into
maindotnet/runtime:mainfrom
copilot/add-uri-scheme-data-constantdotnet/runtime:copilot/add-uri-scheme-data-constantCopy head branch name to clipboard
Jan 14, 2026
Merged

Add Uri.UriSchemeData constant#123147
stephentoub merged 3 commits into
maindotnet/runtime:mainfrom
copilot/add-uri-scheme-data-constantdotnet/runtime:copilot/add-uri-scheme-data-constantCopy head branch name to clipboard

Conversation

Copilot AI commented Jan 13, 2026

Copy link
Copy Markdown
Contributor

Description

Adds UriSchemeData constant to System.Uri for data: URIs, following the pattern established in .NET 6 for adding scheme constants.

namespace System
{
    public partial class Uri
    {
        /// <summary>Specifies that the URI is a data URI.</summary>
        public static readonly string UriSchemeData = "data";
    }
}

Changes:

  • Added UriSchemeData field to System.Private.Uri/src/System/Uri.cs with XML documentation comment
  • Added corresponding declaration to System.Runtime/ref/System.Runtime.cs

Customer Impact

Enables use of Uri.UriSchemeData instead of hardcoding "data" when working with data URIs.

Regression

No, this is a new API addition.

Testing

All existing Uri tests pass. Build succeeds with 0 warnings and 0 errors.

Risk

Minimal. Additive API only—no behavioral changes to existing code.

Package authoring no longer needed in .NET 9

IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.

Original prompt

This section details on the original issue you should resolve

<issue_title>Consider adding Uri.UriSchemeData</issue_title>
<issue_description>### Is your feature request related to a problem? Please describe.

We have constants for http, https, etc., but not for data: URIs.

Describe the solution you'd like

A new constant in the System.Uri class:

namespace System
{
    public partial class Uri
    {
        public static readonly string UriSchemeHttp;
        public static readonly string UriSchemeHttps;
        // +14 other schemes following the same pattern

+       public static readonly string UriSchemeData = "data";
    }
}

Additional context

n/a</issue_description>

Comments on the Issue (you are @copilot in this section)

@MihaZupan Sounds like a reasonable thing to add, we opened the door to adding more constants here with .NET 6 https://github.com//issues/35180#issuecomment-670645017. `data` feels common enough to include.

For reference here's the current list

public static readonly string UriSchemeFile = UriParser.FileUri.SchemeName;
public static readonly string UriSchemeFtp = UriParser.FtpUri.SchemeName;
public static readonly string UriSchemeSftp = "sftp";
public static readonly string UriSchemeFtps = "ftps";
public static readonly string UriSchemeGopher = UriParser.GopherUri.SchemeName;
public static readonly string UriSchemeHttp = UriParser.HttpUri.SchemeName;
public static readonly string UriSchemeHttps = UriParser.HttpsUri.SchemeName;
public static readonly string UriSchemeWs = UriParser.WsUri.SchemeName;
public static readonly string UriSchemeWss = UriParser.WssUri.SchemeName;
public static readonly string UriSchemeMailto = UriParser.MailToUri.SchemeName;
public static readonly string UriSchemeNews = UriParser.NewsUri.SchemeName;
public static readonly string UriSchemeNntp = UriParser.NntpUri.SchemeName;
public static readonly string UriSchemeSsh = "ssh";
public static readonly string UriSchemeTelnet = UriParser.TelnetUri.SchemeName;
public static readonly string UriSchemeNetTcp = UriParser.NetTcpUri.SchemeName;
public static readonly string UriSchemeNetPipe = UriParser.NetPipeUri.SchemeName;
</comment_new>
<comment_new>@bartonjs

  • Looks good as proposed
namespace System
{
    public partial class Uri
    {
        public static readonly string UriSchemeData = "data";
    }
}
```</body></comment_new>
</comments>

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copilot AI changed the title [WIP] Add UriSchemeData constant to System.Uri class Add Uri.UriSchemeData constant Jan 13, 2026
Copilot AI requested a review from stephentoub January 13, 2026 19:51
@MihaZupan
MihaZupan marked this pull request as ready for review January 13, 2026 19:57
Copilot AI review requested due to automatic review settings January 13, 2026 19:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new constant UriSchemeData = "data" to the System.Uri class to enable developers to reference the data: scheme without hardcoding string literals, following the pattern established for other URI schemes.

Changes:

  • Added UriSchemeData constant to the implementation in System.Private.Uri
  • Added corresponding reference assembly declaration in System.Runtime

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/libraries/System.Private.Uri/src/System/Uri.cs Adds the UriSchemeData = "data" constant at the end of the URI scheme constants list
src/libraries/System.Runtime/ref/System.Runtime.cs Adds the UriSchemeData declaration in alphabetical order in the reference assembly

Comment thread src/libraries/System.Private.Uri/src/System/Uri.cs
@MihaZupan MihaZupan added this to the 11.0.0 milestone Jan 13, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Comment thread src/libraries/System.Private.Uri/src/System/Uri.cs
Comment thread src/libraries/System.Runtime/ref/System.Runtime.cs
Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com>
@stephentoub
stephentoub enabled auto-merge (squash) January 13, 2026 21:14
@stephentoub
stephentoub merged commit 8b78bec into main Jan 14, 2026
92 checks passed
@jkotas
jkotas deleted the copilot/add-uri-scheme-data-constant branch January 24, 2026 03:48
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider adding Uri.UriSchemeData

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.