Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ dotnet_diagnostic.RCS1266.severity = warning
# Unnecessary conditional access.
dotnet_diagnostic.RCS9003.severity = warning

[**/Migrations/**.cs]
dotnet_analyzer_diagnostic.severity = none
dotnet_diagnostic.IDE0005.severity = none
dotnet_diagnostic.IDE0300.severity = none

# netstandard2.0
[src/HotChocolate/{Core/src/Types.Analyzers,Language}/**/*.cs]
dotnet_diagnostic.CA1510.severity = none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ internal static partial class Query
"Parameter doc.");
}

[Fact]
[Fact]
public void XmlDocumentation_ForMethod_WithInheritdoc_Inside_Summary()
{
var snapshot =
Expand Down Expand Up @@ -316,7 +316,7 @@ internal static partial class Query
"My Parameter doc.");
}

[Fact]
[Fact]
public void XmlDocumentation_ForMethod_WithInheritdoc_Inside_Param()
{
var snapshot =
Expand Down Expand Up @@ -364,7 +364,7 @@ internal static partial class Query
"My Parameter doc. Inherited: Parameter doc.");
}

[Fact]
[Fact]
public void XmlDocumentation_ForMethod_WithInheritdoc_Inside_Returns()
{
var snapshot =
Expand Down Expand Up @@ -412,7 +412,7 @@ internal static partial class Query
"My Parameter doc.");
}

[Fact]
[Fact]
public void XmlDocumentation_ForMethod_WithInheritdoc_Inside_Exception()
{
var snapshot =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using HotChocolate.Execution;
using HotChocolate.Execution.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace HotChocolate.Resolvers;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using HotChocolate.Configuration;
using HotChocolate.Features;
using HotChocolate.Utilities;
using Microsoft.Extensions.DependencyInjection;

namespace HotChocolate.Types.Descriptors;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,13 @@ bool IsEmptyOperation(OperationPlanStep step)
return step.Definition.SelectionSet.Selections is
[
FieldNode
#pragma warning disable format
{
Alias: null,
Name.Value: IntrospectionFieldNames.TypeName,
Directives: [{ Name.Value: "fusion__empty" }]
}
#pragma warning restore format
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Concurrent;
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using System.Net;
using System.Net.Http.Headers;
using System.Text;
Expand Down
4 changes: 4 additions & 0 deletions src/Mocha/src/Demo/Demo.Billing/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ await db.Invoices.Include(i => i.Payments).FirstOrDefaultAsync(i => i.OrderId ==
{
var invoice = await db.Invoices.FirstOrDefaultAsync(i => i.Id == invoiceId);
if (invoice is null)
{
return Results.NotFound("Invoice not found");
}

if (invoice.Status == InvoiceStatus.Paid)
{
return Results.BadRequest("Invoice already paid");
}

var payment = new Payment
{
Expand Down
2 changes: 0 additions & 2 deletions src/Mocha/src/Demo/Demo.Catalog/Data/CatalogDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Demo.Catalog.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Mocha.Outbox;
using Mocha.Sagas.EfCore;

Expand Down
16 changes: 14 additions & 2 deletions src/Mocha/src/Demo/Demo.Catalog/JsonTopologyPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Explorer;
/// </summary>
public class JsonTopologyPrinter
{
private static readonly JsonSerializerOptions JsonOptions = new()
private static readonly JsonSerializerOptions s_jsonOptions = new()
{
WriteIndented = true,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
Expand Down Expand Up @@ -50,7 +50,7 @@ public string PrintTopology(MessagingRuntime runtime)
ArgumentNullException.ThrowIfNull(runtime);

var model = BuildTopologyModel(runtime);
return JsonSerializer.Serialize(model, JsonOptions);
return JsonSerializer.Serialize(model, s_jsonOptions);
}

public JsonBusModel BuildTopologyModel(MessagingRuntime runtime)
Expand Down Expand Up @@ -287,14 +287,18 @@ private static JsonTopologyModel ExportGenericTopology(MessagingTransport transp
foreach (var endpoint in transport.ReceiveEndpoints)
{
if (endpoint.Source is not null)
{
outboundResources.Add(endpoint.Source);
}
}

// Dispatch endpoints connect to inbound resources (messages flow INTO transport)
foreach (var endpoint in transport.DispatchEndpoints)
{
if (endpoint.Destination is not null)
{
inboundResources.Add(endpoint.Destination);
}
}

foreach (var resource in outboundResources)
Expand All @@ -312,7 +316,9 @@ private static JsonTopologyModel ExportGenericTopology(MessagingTransport transp
{
// Skip if already added as outbound (resource used for both directions)
if (outboundResources.Contains(resource))
{
continue;
}

entities.Add(
new JsonTopologyEntity
Expand All @@ -338,12 +344,16 @@ private static JsonTopologyModel ExportGenericTopology(MessagingTransport transp
foreach (var consumer in runtime.Consumers)
{
if (consumer is not SagaConsumer sagaConsumer)
{
continue;
}

// Access the saga through reflection since SagaConsumer uses a primary constructor
var saga = GetSagaFromConsumer(sagaConsumer);
if (saga is null)
{
continue;
}

var sagaModel = new JsonSagaModel
{
Expand Down Expand Up @@ -473,7 +483,9 @@ private static List<JsonSagaTransitionModel> ExportSagaTransitions(SagaState sta
private static string GetTypeName(Type type)
{
if (!type.IsGenericType)
{
return type.Name;
}

var genericTypeName = type.Name.Split('`')[0];
var genericArgs = string.Join(", ", type.GetGenericArguments().Select(GetTypeName));
Expand Down
10 changes: 10 additions & 0 deletions src/Mocha/src/Demo/Demo.Catalog/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,14 @@ await db.Products.Include(p => p.Category).FirstOrDefaultAsync(p => p.Id == id)

var product = await db.Products.FindAsync(request.ProductId);
if (product is null)
{
return Results.NotFound("Product not found");
}

if (product.StockQuantity < request.Quantity)
{
return Results.BadRequest("Insufficient stock");
}

var order = new OrderRecord
{
Expand Down Expand Up @@ -191,7 +195,9 @@ await db.Orders.Include(o => o.Product).FirstOrDefaultAsync(o => o.Id == id) is
// Verify order exists
var order = await db.Orders.FindAsync(request.OrderId);
if (order is null)
{
return Results.NotFound("Order not found");
}

logger.LogInformation("Initiating quick refund saga for order {OrderId}", request.OrderId);

Expand Down Expand Up @@ -232,10 +238,14 @@ await db.Orders.Include(o => o.Product).FirstOrDefaultAsync(o => o.Id == id) is
// Verify order exists
var order = await db.Orders.Include(o => o.Product).FirstOrDefaultAsync(o => o.Id == request.OrderId);
if (order is null)
{
return Results.NotFound("Order not found");
}

if (order.Status != OrderStatus.Delivered && order.Status != OrderStatus.Shipping)
{
return Results.BadRequest($"Order cannot be returned in status: {order.Status}");
}

logger.LogInformation("Creating return label for order {OrderId}", request.OrderId);

Expand Down
7 changes: 5 additions & 2 deletions src/Mocha/src/Demo/Demo.Catalog/Sagas/QuickRefundSaga.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@ protected override void Configure(ISagaDescriptor<RefundSagaState> descriptor)
descriptor
.During(AwaitingRefund)
.OnReply<ProcessRefundResponse>()
.Then((state, response) => { if (response.Success)
.Then((state, response) =>
{
if (response.Success)
{
state.RefundId = response.RefundId;
state.RefundedAmount = response.Amount;
}
else
{
state.FailureReason = response.FailureReason ?? "Refund processing failed";
} })
}
})
.TransitionTo(Completed);

// Note: We handle both success and failure in the same transition,
Expand Down
14 changes: 10 additions & 4 deletions src/Mocha/src/Demo/Demo.Catalog/Sagas/ReturnProcessingSaga.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ protected override void Configure(ISagaDescriptor<RefundSagaState> descriptor)
descriptor
.During(AwaitingBothReplies)
.OnReply<ProcessRefundResponse>()
.Then((state, response) => { if (response.Success)
.Then((state, response) =>
{
if (response.Success)
{
state.RefundId = response.RefundId;
state.RefundedAmount = response.Amount;
Expand All @@ -62,14 +64,17 @@ protected override void Configure(ISagaDescriptor<RefundSagaState> descriptor)
else
{
state.FailureReason = response.FailureReason;
} })
}
})
.TransitionTo(RefundDoneAwaitingRestock);

// Waiting for refund after restock done
descriptor
.During(RestockDoneAwaitingRefund)
.OnReply<ProcessRefundResponse>()
.Then((state, response) => { if (response.Success)
.Then((state, response) =>
{
if (response.Success)
{
state.RefundId = response.RefundId;
state.RefundedAmount = response.Amount;
Expand All @@ -78,7 +83,8 @@ protected override void Configure(ISagaDescriptor<RefundSagaState> descriptor)
else
{
state.FailureReason = response.FailureReason;
} })
}
})
.TransitionTo(Completed);

// Waiting for restock after refund done
Expand Down
Loading
Loading