Audit protocol types (#892)

This commit is contained in:
Mackinnon Buck 2025-11-04 18:41:10 -05:00 • committed by GitHub
commit 121929da36
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,6 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
@ -38,7 +39,8 @@ public abstract class ResourceContents
/// Gets or sets the URI of the resource.
/// </summary>
[JsonPropertyName("uri")]
public string Uri { get; set; } = string.Empty;
[StringSyntax(StringSyntaxAttribute.Uri)]
public required string Uri { get; set; }
/// <summary>
/// Gets or sets the MIME type of the resource content.
@ -155,7 +157,7 @@ public abstract class ResourceContents
writer.WriteStartObject();
writer.WriteString("uri", value.Uri);
writer.WriteString("mimeType", value.MimeType);
Debug.Assert(value is BlobResourceContents or TextResourceContents);
if (value is BlobResourceContents blobResource)
{