Skip to content

Commit 20f6579

Browse files
committed
dotnet format
1 parent 7cd9b81 commit 20f6579

File tree

4 files changed

+27
-22
lines changed

4 files changed

+27
-22
lines changed

tools/Azure.Mcp.Tools.EventGrid/src/Models/EventGridEventSchema.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ public sealed class EventGridEventSchema
2828

2929
[JsonPropertyName("eventTime")]
3030
public DateTimeOffset EventTime { get; set; }
31-
}
31+
}

tools/Azure.Mcp.Tools.EventGrid/src/Services/EventGridService.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -226,40 +226,40 @@ private static EventGridEventSchema CreateEventGridEventSchemaFromJsonElement(Js
226226
{
227227
string? eventType, subject, dataVersion;
228228
DateTimeOffset eventTime;
229-
229+
230230
// Extract event ID early for logging purposes
231231
var id = eventElement.TryGetProperty("id", out var idProp) ? idProp.GetString() : Guid.NewGuid().ToString();
232-
232+
233233
if (eventSchema.Equals("CloudEvents", StringComparison.OrdinalIgnoreCase))
234234
{
235235
// CloudEvents spec handling (v1.0)
236236
eventType = eventElement.TryGetProperty("type", out var typeProp) ? typeProp.GetString() : "CustomEvent";
237-
237+
238238
// CloudEvents uses "source" field, but we can fall back to "subject" for compatibility
239239
subject = eventElement.TryGetProperty("source", out var sourceProp) ? sourceProp.GetString() :
240240
eventElement.TryGetProperty("subject", out var subjectProp) ? subjectProp.GetString() : "/default/subject";
241-
241+
242242
// CloudEvents uses "specversion" for schema version
243243
dataVersion = eventElement.TryGetProperty("specversion", out var specProp) ? specProp.GetString() : "1.0";
244-
244+
245245
// CloudEvents uses "time" field
246246
eventTime = eventElement.TryGetProperty("time", out var timeProp) && timeProp.TryGetDateTimeOffset(out var timeValue)
247247
? timeValue : DateTimeOffset.UtcNow;
248-
248+
249249
// Handle datacontenttype - CloudEvents v1.0 spec field for content type of data payload
250-
var dataContentType = eventElement.TryGetProperty("datacontenttype", out var dataContentTypeProp)
251-
? dataContentTypeProp.GetString()
250+
var dataContentType = eventElement.TryGetProperty("datacontenttype", out var dataContentTypeProp)
251+
? dataContentTypeProp.GetString()
252252
: "application/json"; // Default per CloudEvents spec
253-
253+
254254
// Log and validate datacontenttype for debugging and monitoring purposes
255-
255+
256256
if (!string.Equals(dataContentType, "application/json", StringComparison.OrdinalIgnoreCase))
257257
{
258258
// Log when non-JSON content types are used - this helps with debugging
259259
// Note: EventGrid will accept the event regardless of datacontenttype,
260260
// but subscribers should handle non-JSON content types appropriately
261261
// Common non-JSON types: application/xml, text/plain, application/octet-stream
262-
262+
263263
// For now, we'll just validate that it's a recognized MIME type format
264264
if (string.IsNullOrWhiteSpace(dataContentType) || !dataContentType.Contains('/'))
265265
{

tools/Azure.Mcp.Tools.EventGrid/tests/Azure.Mcp.Tools.EventGrid.LiveTests/EventGridCommandTests.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,11 @@ public async Task Should_publish_cloudevents_to_eventgrid_topic()
156156
source = "/live/test/cloudevents",
157157
id = Guid.NewGuid().ToString(),
158158
time = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ"),
159-
data = new {
160-
message = "CloudEvents test from live integration test",
159+
data = new
160+
{
161+
message = "CloudEvents test from live integration test",
161162
testType = "live-test",
162-
timestamp = DateTime.UtcNow
163+
timestamp = DateTime.UtcNow
163164
}
164165
});
165166

@@ -192,14 +193,16 @@ public async Task Should_publish_custom_schema_to_eventgrid_topic()
192193
eventCategory = "OrderProcessed",
193194
resourcePath = "/orders/live-test",
194195
occurredAt = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ"),
195-
details = new {
196+
details = new
197+
{
196198
amount = 125.50m,
197199
currency = "USD",
198200
items = new[] {
199201
new { sku = "LIVE-SKU-001", quantity = 2, price = 50.00m },
200202
new { sku = "LIVE-SKU-002", quantity = 1, price = 25.50m }
201203
},
202-
customer = new {
204+
customer = new
205+
{
203206
id = "CUST-LIVE-001",
204207
tier = "premium"
205208
}
@@ -281,10 +284,11 @@ public async Task Should_handle_eventgrid_schema_explicitly()
281284
eventType = "LiveTest.ExplicitEventGrid",
282285
dataVersion = "1.5",
283286
eventTime = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ"),
284-
data = new {
287+
data = new
288+
{
285289
isExplicit = true,
286290
schema = "EventGrid",
287-
timestamp = DateTime.UtcNow
291+
timestamp = DateTime.UtcNow
288292
}
289293
});
290294

@@ -316,9 +320,10 @@ public async Task Should_publish_with_default_schema_when_not_specified()
316320
subject = "/live/test/default",
317321
eventType = "LiveTest.DefaultSchema",
318322
dataVersion = "1.0",
319-
data = new {
323+
data = new
324+
{
320325
defaultTest = true,
321-
timestamp = DateTime.UtcNow
326+
timestamp = DateTime.UtcNow
322327
}
323328
});
324329

tools/Azure.Mcp.Tools.EventGrid/tests/Azure.Mcp.Tools.EventGrid.UnitTests/Events/EventsPublishCommandTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ public async Task ExecuteAsync_WithLargeEventPayload_ReturnsSuccess()
634634
var subscriptionId = "test-sub";
635635
var resourceGroup = "test-rg";
636636
var topicName = "test-topic";
637-
637+
638638
// Create a large data payload
639639
var largeData = new
640640
{

0 commit comments

Comments
 (0)