Skip to content

Commit 55bda78

Browse files
Styling: remove a few redundant parens from object initializer expressions. (#548)
* Styling: remove a few redundant parens from object initializer expressions. * Fix build error.
1 parent 802424e commit 55bda78

23 files changed

+108
-108
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,17 @@ using System.Text.Json;
173173

174174
McpServerOptions options = new()
175175
{
176-
ServerInfo = new Implementation() { Name = "MyServer", Version = "1.0.0" },
177-
Capabilities = new ServerCapabilities()
176+
ServerInfo = new Implementation { Name = "MyServer", Version = "1.0.0" },
177+
Capabilities = new ServerCapabilities
178178
{
179-
Tools = new ToolsCapability()
179+
Tools = new ToolsCapability
180180
{
181181
ListToolsHandler = (request, cancellationToken) =>
182-
ValueTask.FromResult(new ListToolsResult()
182+
ValueTask.FromResult(new ListToolsResult
183183
{
184184
Tools =
185185
[
186-
new Tool()
186+
new Tool
187187
{
188188
Name = "echo",
189189
Description = "Echoes the input back to the client.",

samples/EverythingServer/Tools/AnnotatedMessageTool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static IEnumerable<ContentBlock> AnnotatedMessage(MessageType messageType
3939

4040
if (includeImage)
4141
{
42-
contents.Add(new ImageContentBlock()
42+
contents.Add(new ImageContentBlock
4343
{
4444
Data = TinyImageTool.MCP_TINY_IMAGE.Split(",").Last(),
4545
MimeType = "image/png",

samples/EverythingServer/Tools/SampleLlmTool.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ public static async Task<string> SampleLLM(
2222

2323
private static CreateMessageRequestParams CreateRequestSamplingParams(string context, string uri, int maxTokens = 100)
2424
{
25-
return new CreateMessageRequestParams()
25+
return new CreateMessageRequestParams
2626
{
27-
Messages = [new SamplingMessage()
27+
Messages = [new SamplingMessage
2828
{
2929
Role = Role.User,
3030
Content = new TextContentBlock { Text = $"Resource {uri} context: {context}" },

samples/TestServerWithHosting/Tools/SampleLlmTool.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ public static async Task<string> SampleLLM(
2525

2626
private static CreateMessageRequestParams CreateRequestSamplingParams(string context, string uri, int maxTokens = 100)
2727
{
28-
return new CreateMessageRequestParams()
28+
return new CreateMessageRequestParams
2929
{
30-
Messages = [new SamplingMessage()
30+
Messages = [new SamplingMessage
3131
{
3232
Role = Role.User,
3333
Content = new TextContentBlock { Text = $"Resource {uri} context: {context}" },

src/ModelContextProtocol.Core/AIContentExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,21 +188,21 @@ internal static ContentBlock ToContent(this AIContent content) =>
188188
Text = textContent.Text,
189189
},
190190

191-
DataContent dataContent when dataContent.HasTopLevelMediaType("image") => new ImageContentBlock()
191+
DataContent dataContent when dataContent.HasTopLevelMediaType("image") => new ImageContentBlock
192192
{
193193
Data = dataContent.Base64Data.ToString(),
194194
MimeType = dataContent.MediaType,
195195
},
196196

197-
DataContent dataContent when dataContent.HasTopLevelMediaType("audio") => new AudioContentBlock()
197+
DataContent dataContent when dataContent.HasTopLevelMediaType("audio") => new AudioContentBlock
198198
{
199199
Data = dataContent.Base64Data.ToString(),
200200
MimeType = dataContent.MediaType,
201201
},
202202

203-
DataContent dataContent => new EmbeddedResourceBlock()
203+
DataContent dataContent => new EmbeddedResourceBlock
204204
{
205-
Resource = new BlobResourceContents()
205+
Resource = new BlobResourceContents
206206
{
207207
Blob = dataContent.Base64Data.ToString(),
208208
MimeType = dataContent.MediaType,

src/ModelContextProtocol.Core/Protocol/ContentBlock.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,30 +149,30 @@ public class Converter : JsonConverter<ContentBlock>
149149
Meta = meta,
150150
},
151151

152-
"image" => new ImageContentBlock()
152+
"image" => new ImageContentBlock
153153
{
154154
Data = data ?? throw new JsonException("Image data must be provided for 'image' type."),
155155
MimeType = mimeType ?? throw new JsonException("MIME type must be provided for 'image' type."),
156156
Annotations = annotations,
157157
Meta = meta,
158158
},
159159

160-
"audio" => new AudioContentBlock()
160+
"audio" => new AudioContentBlock
161161
{
162162
Data = data ?? throw new JsonException("Audio data must be provided for 'audio' type."),
163163
MimeType = mimeType ?? throw new JsonException("MIME type must be provided for 'audio' type."),
164164
Annotations = annotations,
165165
Meta = meta,
166166
},
167167

168-
"resource" => new EmbeddedResourceBlock()
168+
"resource" => new EmbeddedResourceBlock
169169
{
170170
Resource = resource ?? throw new JsonException("Resource contents must be provided for 'resource' type."),
171171
Annotations = annotations,
172172
Meta = meta,
173173
},
174174

175-
"resource_link" => new ResourceLinkBlock()
175+
"resource_link" => new ResourceLinkBlock
176176
{
177177
Uri = uri ?? throw new JsonException("URI must be provided for 'resource_link' type."),
178178
Name = name ?? throw new JsonException("Name must be provided for 'resource_link' type."),

src/ModelContextProtocol.Core/Protocol/ProgressNotificationParams.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public sealed class Converter : JsonConverter<ProgressNotificationParams>
9898
return new ProgressNotificationParams
9999
{
100100
ProgressToken = progressToken.GetValueOrDefault(),
101-
Progress = new ProgressNotificationValue()
101+
Progress = new ProgressNotificationValue
102102
{
103103
Progress = progress.GetValueOrDefault(),
104104
Total = total,

src/ModelContextProtocol.Core/Server/AIFunctionMcpServerResource.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,14 +421,14 @@ private AIFunctionMcpServerResource(AIFunction function, ResourceTemplate resour
421421
Contents = aiContents.Select<AIContent, ResourceContents>(
422422
ac => ac switch
423423
{
424-
TextContent tc => new TextResourceContents()
424+
TextContent tc => new TextResourceContents
425425
{
426426
Uri = request.Params!.Uri,
427427
MimeType = ProtocolResourceTemplate.MimeType,
428428
Text = tc.Text
429429
},
430430

431-
DataContent dc => new BlobResourceContents()
431+
DataContent dc => new BlobResourceContents
432432
{
433433
Uri = request.Params!.Uri,
434434
MimeType = dc.MediaType,
@@ -441,7 +441,7 @@ private AIFunctionMcpServerResource(AIFunction function, ResourceTemplate resour
441441

442442
IEnumerable<string> strings => new()
443443
{
444-
Contents = strings.Select<string, ResourceContents>(text => new TextResourceContents()
444+
Contents = strings.Select<string, ResourceContents>(text => new TextResourceContents
445445
{
446446
Uri = request.Params!.Uri,
447447
MimeType = ProtocolResourceTemplate.MimeType,

src/ModelContextProtocol.Core/Server/McpServerExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ public static async Task<ChatResponse> SampleAsync(
103103
{
104104
Role = role,
105105
Content = dataContent.HasTopLevelMediaType("image") ?
106-
new ImageContentBlock()
106+
new ImageContentBlock
107107
{
108108
MimeType = dataContent.MediaType,
109109
Data = dataContent.Base64Data.ToString(),
110110
} :
111-
new AudioContentBlock()
111+
new AudioContentBlock
112112
{
113113
MimeType = dataContent.MediaType,
114114
Data = dataContent.Base64Data.ToString(),
@@ -344,7 +344,7 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
344344

345345
void Log(LogLevel logLevel, string message)
346346
{
347-
_ = server.SendNotificationAsync(NotificationMethods.LoggingMessageNotification, new LoggingMessageNotificationParams()
347+
_ = server.SendNotificationAsync(NotificationMethods.LoggingMessageNotification, new LoggingMessageNotificationParams
348348
{
349349
Level = McpServer.ToLoggingLevel(logLevel),
350350
Data = JsonSerializer.SerializeToElement(message, McpJsonUtilities.JsonContext.Default.String),

tests/ModelContextProtocol.AspNetCore.Tests/MapMcpTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected async Task<IMcpClient> ConnectAsync(
3131
// Default behavior when no options are provided
3232
path ??= UseStreamableHttp ? "/" : "/sse";
3333

34-
await using var transport = new SseClientTransport(transportOptions ?? new SseClientTransportOptions()
34+
await using var transport = new SseClientTransport(transportOptions ?? new SseClientTransportOptions
3535
{
3636
Endpoint = new Uri($"http://localhost{path}"),
3737
TransportMode = UseStreamableHttp ? HttpTransportMode.StreamableHttp : HttpTransportMode.Sse,

0 commit comments

Comments
 (0)