Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit 1ee9625

Browse files
committed
Upgrade security warning package. Minor warning fixes as well.
1 parent ad358b2 commit 1ee9625

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

src/Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,6 @@
8888
<PackageVersion Include="System.Reflection.TypeExtensions" Version="4.7.0" />
8989
<PackageVersion Include="xunit" Version="2.4.2" />
9090
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
91-
<PackageVersion Include="Yarp.ReverseProxy" Version="2.0.0" />
91+
<PackageVersion Include="Yarp.ReverseProxy" Version="2.0.1" />
9292
</ItemGroup>
9393
</Project>

src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,26 @@ public class Order
1919

2020
private string _description;
2121

22-
23-
2422
// Draft orders have this set to true. Currently we don't check anywhere the draft status of an Order, but we could do it if needed
23+
#pragma warning disable CS0414 // The field 'Order._isDraft' is assigned but its value is never used
2524
private bool _isDraft;
25+
#pragma warning restore CS0414
2626

2727
// DDD Patterns comment
2828
// Using a private collection field, better for DDD Aggregate's encapsulation
2929
// so OrderItems cannot be added from "outside the AggregateRoot" directly to the collection,
30-
// but only through the method OrderAggrergateRoot.AddOrderItem() which includes behaviour.
30+
// but only through the method OrderAggregateRoot.AddOrderItem() which includes behavior.
3131
private readonly List<OrderItem> _orderItems;
3232
public IReadOnlyCollection<OrderItem> OrderItems => _orderItems;
3333

3434
private int? _paymentMethodId;
3535

3636
public static Order NewDraft()
3737
{
38-
var order = new Order();
39-
order._isDraft = true;
38+
var order = new Order
39+
{
40+
_isDraft = true
41+
};
4042
return order;
4143
}
4244

@@ -56,13 +58,13 @@ public Order(string userId, string userName, Address address, int cardTypeId, st
5658
Address = address;
5759

5860
// Add the OrderStarterDomainEvent to the domain events collection
59-
// to be raised/dispatched when comitting changes into the Database [ After DbContext.SaveChanges() ]
61+
// to be raised/dispatched when committing changes into the Database [ After DbContext.SaveChanges() ]
6062
AddOrderStartedDomainEvent(userId, userName, cardTypeId, cardNumber,
6163
cardSecurityNumber, cardHolderName, cardExpiration);
6264
}
6365

6466
// DDD Patterns comment
65-
// This Order AggregateRoot's method "AddOrderitem()" should be the only way to add Items to the Order,
67+
// This Order AggregateRoot's method "AddOrderItem()" should be the only way to add Items to the Order,
6668
// so any behavior (discounts, etc.) and validations are controlled by the AggregateRoot
6769
// in order to maintain consistency between the whole Aggregate.
6870
public void AddOrderItem(int productId, string productName, decimal unitPrice, decimal discount, string pictureUrl, int units = 1)

src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public async Task<bool> SaveEntitiesAsync(CancellationToken cancellationToken =
5050

5151
// After executing this line all the changes (from the Command Handler and Domain Event Handlers)
5252
// performed through the DbContext will be committed
53-
var result = await base.SaveChangesAsync(cancellationToken);
53+
_ = await base.SaveChangesAsync(cancellationToken);
5454

5555
return true;
5656
}
@@ -106,6 +106,8 @@ public void RollbackTransaction()
106106
}
107107
}
108108

109+
#nullable enable
110+
109111
public class OrderingContextDesignFactory : IDesignTimeDbContextFactory<OrderingContext>
110112
{
111113
public OrderingContext CreateDbContext(string[] args)
@@ -120,12 +122,12 @@ class NoMediator : IMediator
120122
{
121123
public IAsyncEnumerable<TResponse> CreateStream<TResponse>(IStreamRequest<TResponse> request, CancellationToken cancellationToken = default)
122124
{
123-
return default;
125+
return default!;
124126
}
125127

126128
public IAsyncEnumerable<object?> CreateStream(object request, CancellationToken cancellationToken = default)
127129
{
128-
return default;
130+
return default!;
129131
}
130132

131133
public Task Publish<TNotification>(TNotification notification, CancellationToken cancellationToken = default) where TNotification : INotification
@@ -140,10 +142,10 @@ public Task Publish(object notification, CancellationToken cancellationToken = d
140142

141143
public Task<TResponse> Send<TResponse>(IRequest<TResponse> request, CancellationToken cancellationToken = default)
142144
{
143-
return Task.FromResult<TResponse>(default);
145+
return Task.FromResult<TResponse>(default!);
144146
}
145147

146-
public Task<object> Send(object request, CancellationToken cancellationToken = default)
148+
public Task<object?> Send(object request, CancellationToken cancellationToken = default)
147149
{
148150
return Task.FromResult(default(object));
149151
}

src/Services/Services.Common/AuthorizeCheckOperationFilter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public AuthorizeCheckOperationFilter(IConfiguration configuration)
1616
public void Apply(OpenApiOperation operation, OperationFilterContext context)
1717
{
1818
// Check for authorize attribute
19-
var hasAuthorize = context.MethodInfo.DeclaringType.GetCustomAttributes(true).OfType<AuthorizeAttribute>().Any() ||
20-
context.MethodInfo.GetCustomAttributes(true).OfType<AuthorizeAttribute>().Any();
19+
var hasAuthorize = context.MethodInfo.DeclaringType?.GetCustomAttributes(true)?.OfType<AuthorizeAttribute>().Any() ?? false
20+
|| context.MethodInfo.GetCustomAttributes(true).OfType<AuthorizeAttribute>().Any();
2121

2222
if (!hasAuthorize) return;
2323

0 commit comments

Comments
 (0)