Add net10.0 assets and run some fixers (#875)
This commit is contained in:
parent
e7b403b820
commit
bfc0980ef5
14 changed files with 168 additions and 194 deletions
|
|
@ -448,7 +448,7 @@ public class AuthorizeAttributeTests(ITestOutputHelper testOutputHelper) : Kestr
|
|||
}
|
||||
|
||||
private ClaimsPrincipal CreateUser(string name, params string[] roles)
|
||||
=> new ClaimsPrincipal(new ClaimsIdentity(
|
||||
=> new(new ClaimsIdentity(
|
||||
[new Claim("name", name), new Claim(ClaimTypes.NameIdentifier, name), .. roles.Select(role => new Claim("role", role))],
|
||||
"TestAuthType", "name", "role"));
|
||||
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ public abstract class MapMcpTests(ITestOutputHelper testOutputHelper) : KestrelI
|
|||
}
|
||||
|
||||
private ClaimsPrincipal CreateUser(string name)
|
||||
=> new ClaimsPrincipal(new ClaimsIdentity(
|
||||
=> new(new ClaimsIdentity(
|
||||
[new Claim("name", name), new Claim(ClaimTypes.NameIdentifier, name)],
|
||||
"TestAuthType", "name", "role"));
|
||||
|
||||
|
|
|
|||
|
|
@ -556,7 +556,7 @@ public class StreamableHttpServerConformanceTests(ITestOutputHelper outputHelper
|
|||
Assert.Equal(NotificationMethods.ResourceUpdatedNotification, notification.Method);
|
||||
}
|
||||
|
||||
private static StringContent JsonContent(string json) => new StringContent(json, Encoding.UTF8, "application/json");
|
||||
private static StringContent JsonContent(string json) => new(json, Encoding.UTF8, "application/json");
|
||||
private static JsonTypeInfo<T> GetJsonTypeInfo<T>() => (JsonTypeInfo<T>)McpJsonUtilities.DefaultOptions.GetTypeInfo(typeof(T));
|
||||
|
||||
private static T AssertType<T>(JsonNode? jsonNode)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ internal sealed class AuthorizationServerMetadata
|
|||
/// Gets the introspection endpoint URL.
|
||||
/// </summary>
|
||||
[JsonPropertyName("introspection_endpoint")]
|
||||
public Uri? IntrospectionEndpoint => new Uri($"{Issuer}/introspect");
|
||||
public Uri? IntrospectionEndpoint => new($"{Issuer}/introspect");
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the response types supported by this server.
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ public class Program
|
|||
}
|
||||
#endregion
|
||||
|
||||
List<Resource> resources = new();
|
||||
List<ResourceContents> resourceContents = new();
|
||||
List<Resource> resources = [];
|
||||
List<ResourceContents> resourceContents = [];
|
||||
for (int i = 0; i < 100; ++i)
|
||||
{
|
||||
string uri = $"test://static/resource/{i + 1}";
|
||||
|
|
@ -319,7 +319,7 @@ public class Program
|
|||
{
|
||||
throw new McpProtocolException("Missing required parameter 'name'", McpErrorCode.InvalidParams);
|
||||
}
|
||||
List<PromptMessage> messages = new();
|
||||
List<PromptMessage> messages = [];
|
||||
if (request.Params.Name == "simple_prompt")
|
||||
{
|
||||
messages.Add(new PromptMessage
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public class DiagnosticTests
|
|||
{
|
||||
await client.CallToolAsync("Throw", cancellationToken: TestContext.Current.CancellationToken);
|
||||
await Assert.ThrowsAsync<McpProtocolException>(async () => await client.CallToolAsync("does-not-exist", cancellationToken: TestContext.Current.CancellationToken));
|
||||
}, new List<string>());
|
||||
}, []);
|
||||
}
|
||||
|
||||
Assert.NotEmpty(activities);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public static class IconTests
|
|||
{
|
||||
Source = "https://example.com/icon.png",
|
||||
MimeType = "image/png",
|
||||
Sizes = new List<string> { "48x48" },
|
||||
Sizes = ["48x48"],
|
||||
Theme = "light"
|
||||
};
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ public static class IconTests
|
|||
{
|
||||
Source = "https://example.com/icon.svg",
|
||||
MimeType = "image/svg+xml",
|
||||
Sizes = new List<string> { "any" },
|
||||
Sizes = ["any"],
|
||||
Theme = "dark"
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ public static class ImplementationTests
|
|||
Version = "1.0.0",
|
||||
Icons =
|
||||
[
|
||||
new() { Source = "https://example.com/icon.png", MimeType = "image/png", Sizes = new List<string> { "48x48" } },
|
||||
new() { Source = "https://example.com/icon.svg", MimeType = "image/svg+xml", Sizes = new List<string> { "any" } }
|
||||
new() { Source = "https://example.com/icon.png", MimeType = "image/png", Sizes = ["48x48"] },
|
||||
new() { Source = "https://example.com/icon.svg", MimeType = "image/svg+xml", Sizes = ["any"] }
|
||||
],
|
||||
WebsiteUrl = "https://example.com"
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public static class PromptTests
|
|||
Description = "Review the provided code",
|
||||
Icons =
|
||||
[
|
||||
new() { Source = "https://example.com/review-icon.svg", MimeType = "image/svg+xml", Sizes = new List<string> { "any" } }
|
||||
new() { Source = "https://example.com/review-icon.svg", MimeType = "image/svg+xml", Sizes = ["any"] }
|
||||
],
|
||||
Arguments =
|
||||
[
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public static class ResourceTests
|
|||
Size = 1024,
|
||||
Icons =
|
||||
[
|
||||
new() { Source = "https://example.com/pdf-icon.png", MimeType = "image/png", Sizes = new List<string> { "32x32" } }
|
||||
new() { Source = "https://example.com/pdf-icon.png", MimeType = "image/png", Sizes = ["32x32"] }
|
||||
],
|
||||
Annotations = new Annotations { Audience = [Role.User] }
|
||||
};
|
||||
|
|
@ -86,7 +86,7 @@ public static class ResourceTests
|
|||
Description = "A test resource",
|
||||
MimeType = "text/plain",
|
||||
Size = 512,
|
||||
Icons = new List<Icon> { new() { Source = "https://example.com/icon.svg" } },
|
||||
Icons = [new() { Source = "https://example.com/icon.svg" }],
|
||||
Annotations = new Annotations { Audience = [Role.User] }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public static class ToolTests
|
|||
Description = "Get current weather information",
|
||||
Icons =
|
||||
[
|
||||
new() { Source = "https://example.com/weather.png", MimeType = "image/png", Sizes = new List<string> { "48x48" } }
|
||||
new() { Source = "https://example.com/weather.png", MimeType = "image/png", Sizes = ["48x48"] }
|
||||
],
|
||||
Annotations = new ToolAnnotations
|
||||
{
|
||||
|
|
|
|||
|
|
@ -498,7 +498,7 @@ public class McpServerPromptTests
|
|||
{
|
||||
var icons = new List<Icon>
|
||||
{
|
||||
new() { Source = "https://example.com/prompt-icon.png", MimeType = "image/png", Sizes = new List<string> { "48x48" } }
|
||||
new() { Source = "https://example.com/prompt-icon.png", MimeType = "image/png", Sizes = ["48x48"] }
|
||||
};
|
||||
|
||||
McpServerPrompt prompt = McpServerPrompt.Create(() => "test prompt", new McpServerPromptCreateOptions
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ public partial class McpServerResourceTests
|
|||
{
|
||||
McpServerResource t1 = McpServerResource.Create(() => "resource", new() { UriTemplate = "resource://MyCoolResource" });
|
||||
McpServerResource t2 = McpServerResource.Create(() => "resource", new() { UriTemplate = "resource://MyCoolResource2" });
|
||||
McpServerResourceCollection collection = new() { t1, t2 };
|
||||
McpServerResourceCollection collection = [t1, t2];
|
||||
Assert.True(collection.TryGetPrimitive("resource://mycoolresource", out McpServerResource? result));
|
||||
Assert.Same(t1, result);
|
||||
}
|
||||
|
|
@ -537,7 +537,7 @@ public partial class McpServerResourceTests
|
|||
McpServerResource resource = McpServerResource.Create((McpServer server) =>
|
||||
{
|
||||
Assert.Same(mockServer.Object, server);
|
||||
return new ReadResourceResult { Contents = new List<ResourceContents> { new TextResourceContents { Text = "hello" } } };
|
||||
return new ReadResourceResult { Contents = [new TextResourceContents { Text = "hello" }] };
|
||||
}, new() { Name = "Test" });
|
||||
var result = await resource.ReadAsync(
|
||||
new RequestContext<ReadResourceRequestParams>(mockServer.Object, CreateTestJsonRpcRequest()) { Params = new() { Uri = "resource://mcp/Test" } },
|
||||
|
|
@ -682,7 +682,7 @@ public partial class McpServerResourceTests
|
|||
{
|
||||
var icons = new List<Icon>
|
||||
{
|
||||
new() { Source = "https://example.com/resource-icon.png", MimeType = "image/png", Sizes = new List<string> { "32x32" } }
|
||||
new() { Source = "https://example.com/resource-icon.png", MimeType = "image/png", Sizes = ["32x32"] }
|
||||
};
|
||||
|
||||
McpServerResource resource = McpServerResource.Create(() => "test content", new McpServerResourceCreateOptions
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@ public partial class McpServerToolTests
|
|||
{
|
||||
CallToolResult response = new()
|
||||
{
|
||||
Content = new List<ContentBlock> { new TextContentBlock { Text = "text" }, new ImageContentBlock { Data = "1234", MimeType = "image/png" } }
|
||||
Content = [new TextContentBlock { Text = "text" }, new ImageContentBlock { Data = "1234", MimeType = "image/png" }]
|
||||
};
|
||||
|
||||
Mock<McpServer> mockServer = new();
|
||||
|
|
@ -683,8 +683,8 @@ public partial class McpServerToolTests
|
|||
{
|
||||
var icons = new List<Icon>
|
||||
{
|
||||
new() { Source = "https://example.com/icon.png", MimeType = "image/png", Sizes = new List<string> { "48x48" } },
|
||||
new() { Source = "https://example.com/icon.svg", MimeType = "image/svg+xml", Sizes = new List<string> { "any" } }
|
||||
new() { Source = "https://example.com/icon.png", MimeType = "image/png", Sizes = ["48x48"] },
|
||||
new() { Source = "https://example.com/icon.svg", MimeType = "image/svg+xml", Sizes = ["any"] }
|
||||
};
|
||||
|
||||
McpServerTool tool = McpServerTool.Create(() => "test", new McpServerToolCreateOptions
|
||||
|
|
|
|||
Loading…
Reference in a new issue