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
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public async Task BatchPaging_First_5()
{
First = page.Value.CreateStartCursor(),
Last = page.Value.CreateEndCursor(),
Items = page.Value.Items
page.Value.Items
},
name: page.Key.ToString());
}
Expand Down Expand Up @@ -299,7 +299,7 @@ public async Task BatchPaging_Last_5()
{
First = page.Value.CreateStartCursor(),
Last = page.Value.CreateEndCursor(),
Items = page.Value.Items
page.Value.Items
},
name: page.Key.ToString());
}
Expand Down Expand Up @@ -341,7 +341,7 @@ public async Task BatchPaging_With_Relative_Cursor()
{
First = page.Value.CreateCursor(page.Value.Entries[0], 0),
Last = page.Value.CreateCursor(page.Value.Entries[^1], 0),
Items = page.Value.Items
page.Value.Items
},
name: page.Key.ToString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,21 @@
using System.Diagnostics;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using HotChocolate.Buffers;
using HotChocolate.Language;
using static System.Net.Http.HttpCompletionOption;

#if FUSION
using HotChocolate.Fusion.Transport;
using HotChocolate.Fusion.Transport.Http;
using HotChocolate.Fusion.Transport.Serialization;
using HotChocolate.Text.Json;
using HotChocolate.Transport.Http;
using HotChocolate.Types;
#else
using HotChocolate.Transport.Serialization;
#endif
using static System.Net.Http.HttpCompletionOption;

#if FUSION
namespace HotChocolate.Fusion.Transport.Http;
#else
using System.Text.Json;
using HotChocolate.Transport.Serialization;

namespace HotChocolate.Transport.Http;
#endif

Expand Down Expand Up @@ -179,10 +176,10 @@ private static HttpRequestMessage CreateRequestMessage(
else
{
message.Headers.Accept.Clear();
foreach (var contentType in request.Accept)
{
message.Headers.Accept.Add(contentType);
}
foreach (var contentType in request.Accept)
{
message.Headers.Accept.Add(contentType);
}
}
#else
message.Headers.Accept.Clear();
Expand Down Expand Up @@ -353,8 +350,8 @@ private static IReadOnlyList<FileEntry> CollectFileEntries(IRequestBody body)
{
return body switch
{
OperationRequest { FileMap: { IsDefaultOrEmpty: false } fileMap } => [..fileMap],
OperationBatchRequest { FileMap: { IsDefaultOrEmpty: false } fileMap } => [..fileMap],
OperationRequest { FileMap: { IsDefaultOrEmpty: false } fileMap } => [.. fileMap],
OperationBatchRequest { FileMap: { IsDefaultOrEmpty: false } fileMap } => [.. fileMap],
_ => []
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#if FUSION
using HotChocolate.Fusion.Execution;
using HotChocolate.Transport;
#endif

#if FUSION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#if FUSION
using HotChocolate.Fusion.Execution;
using HotChocolate.Fusion.Execution.Clients;
using HotChocolate.Transport;
using HotChocolate.Transport.Http;
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Net.Http.Headers;
using System.IO.Pipelines;
using HotChocolate.Buffers;
using HotChocolate.Transport;
using HotChocolate.Fusion.Text.Json;
#else
using System.Net;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Diagnostics;
using GreenDonut;
using HotChocolate.Execution;
using HotChocolate.Language;
using HotChocolate.Resolvers;

namespace HotChocolate.Diagnostics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using HotChocolate.Execution;
using HotChocolate.Fusion.Execution;
using HotChocolate.Fusion.Execution.Nodes;
using HotChocolate.Language;

namespace HotChocolate.Fusion.Diagnostics;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using HotChocolate.Fusion.Execution;
using HotChocolate.Fusion.Execution.Clients;
using HotChocolate.Language;
using HotChocolate.Types;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.ObjectPool;
using Microsoft.Extensions.Options;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using HotChocolate.Features;
using HotChocolate.Fusion.Types;
using HotChocolate.Language;
using HotChocolate.Fusion.Transport;
using HotChocolate.Types;

namespace HotChocolate.Fusion.Execution;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using HotChocolate.Language;
using HotChocolate.Resolvers;
using HotChocolate.Transport.Http;
using HotChocolate.Types;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections.Immutable;
using System.Text;
using System.Text.Json;
using HotChocolate.Buffers;
Expand Down Expand Up @@ -272,7 +271,7 @@ public async Task ReadAsResultStream_Single_Application_Json_Lines_Response()
null,
null,
null,
ImmutableArray.Create(VariableValues.Empty),
[VariableValues.Empty],
JsonSegment.Empty);
var request = new GraphQLHttpRequest(operationRequest, new Uri("http://localhost:5000/graphql"));

Expand Down Expand Up @@ -318,7 +317,7 @@ public async Task ReadAsResultStream_Multi_Application_Json_Lines_Response()
null,
null,
null,
ImmutableArray.Create(VariableValues.Empty, VariableValues.Empty),
[VariableValues.Empty, VariableValues.Empty],
JsonSegment.Empty);
var request = new GraphQLHttpRequest(operationRequest, new Uri("http://localhost:5000/graphql"));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Immutable;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Immutable;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Immutable;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Immutable;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Immutable;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Immutable;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Immutable;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Immutable;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
Expand Down
1 change: 0 additions & 1 deletion src/Mocha/src/Mocha.Analyzers/KnownTypeSymbols.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Runtime.CompilerServices;
using System.Threading;
using Microsoft.CodeAnalysis;

namespace Mocha.Analyzers;
Expand Down
1 change: 0 additions & 1 deletion src/Mocha/src/Mocha.Analyzers/MediatorGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Immutable;
using System.Text;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public sealed class ImmutableEquatableArray<T> : IEquatable<ImmutableEquatableAr
/// <summary>
/// Gets an empty <see cref="ImmutableEquatableArray{T}"/>.
/// </summary>
public static ImmutableEquatableArray<T> Empty { get; } = new(ImmutableArray.Create<T>());
public static ImmutableEquatableArray<T> Empty { get; } = new([]);

private readonly ImmutableArray<T> _values;

Expand Down
2 changes: 1 addition & 1 deletion src/Mocha/src/Mocha.Mediator.Abstractions/Unit.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Mocha.Mediator;

/// <summary>
/// Represents a void type since <see cref="System.Void"/> is not a valid generic type argument.
/// Represents a void type since <see cref="Void"/> is not a valid generic type argument.
/// </summary>
/// <remarks>
/// Use <see cref="Unit"/> as the response type for commands that do not return a meaningful value.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;

namespace Mocha.Mediator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static IMediatorHostBuilder AddMediator(this IServiceCollection services,

if (name.Length == 0)
{
services.TryAddSingleton<MediatorRuntime>(sp => BuildRuntime(sp, name));
services.TryAddSingleton(sp => BuildRuntime(sp, name));

services.TryAddScoped<Mediator>();
services.TryAddScoped<IMediator>(sp => sp.GetRequiredService<Mediator>());
Expand All @@ -37,9 +37,9 @@ public static IMediatorHostBuilder AddMediator(this IServiceCollection services,
}
else
{
services.TryAddKeyedSingleton<MediatorRuntime>(name, (sp, _) => BuildRuntime(sp, name));
services.TryAddKeyedSingleton(name, (sp, _) => BuildRuntime(sp, name));

services.TryAddKeyedScoped<Mediator>(name,
services.TryAddKeyedScoped(name,
static (sp, key) => new Mediator(
sp.GetRequiredKeyedService<MediatorRuntime>(key),
sp));
Expand Down
1 change: 0 additions & 1 deletion src/Mocha/src/Mocha.Mediator/Pipeline/PipelineBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Microsoft.Extensions.DependencyInjection;
using Mocha.Features;

namespace Mocha.Mediator;

Expand Down
19 changes: 13 additions & 6 deletions src/Mocha/src/Mocha/Builder/MessageBusBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ public IMessageBusBuilder AddHandler<THandler>(Action<IConsumerDescriptor>? conf
inner(d);
configure(d);
}
#pragma warning disable format
: configure;
#pragma warning restore format
}

return this;
Expand Down Expand Up @@ -143,7 +145,9 @@ public IMessageBusBuilder AddHandler<THandler>(Action<IConsumerDescriptor>? conf

_consumerRegistrations.Add(new ConsumerRegistration
{
HandlerType = handlerType, Configure = configure, Factory = factory
HandlerType = handlerType,
Configure = configure,
Factory = factory
});

return this;
Expand All @@ -164,7 +168,9 @@ public IMessageBusBuilder AddHandlerConfiguration(MessagingHandlerConfiguration

_consumerRegistrations.Add(new ConsumerRegistration
{
HandlerType = handlerType, Configure = null, Factory = configuration.Factory
HandlerType = handlerType,
Configure = null,
Factory = configuration.Factory
});

return this;
Expand Down Expand Up @@ -361,10 +367,11 @@ public MessagingRuntime Build(IServiceProvider applicationServices)
var responseManager = applicationServices.GetRequiredService<DeferredResponseManager>();

// Materialize consumers from registrations
var consumerList = new List<Consumer>();

// Infrastructure consumer
consumerList.Add(new ReplyConsumer(responseManager));
var consumerList = new List<Consumer>
{
// Infrastructure consumer
new ReplyConsumer(responseManager)
};

// Handler consumers from registrations
foreach (var reg in _consumerRegistrations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis.CSharp;
using CookieCrumble;
using Microsoft.Extensions.DependencyInjection;
using Mocha.Analyzers;

namespace Mocha.Analyzers.Tests;

Expand Down
5 changes: 2 additions & 3 deletions src/Mocha/test/Mocha.Analyzers.Tests/TestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using CookieCrumble;
using Mocha.Analyzers;

namespace Mocha.Analyzers.Tests;

Expand All @@ -31,13 +30,13 @@ public static Snapshot GetGeneratedSourceSnapshot(
.. Net100.References.All,
#endif
// Mocha.Mediator
MetadataReference.CreateFromFile(typeof(Mocha.Mediator.IMediator).Assembly.Location),
MetadataReference.CreateFromFile(typeof(Mediator.IMediator).Assembly.Location),

// Microsoft.Extensions.DependencyInjection.Abstractions
MetadataReference.CreateFromFile(typeof(Microsoft.Extensions.DependencyInjection.IServiceCollection).Assembly.Location),

// System.Runtime.CompilerServices.Unsafe
MetadataReference.CreateFromFile(typeof(System.Runtime.CompilerServices.Unsafe).Assembly.Location),
MetadataReference.CreateFromFile(typeof(Unsafe).Assembly.Location),

// System.Runtime from the actual runtime (needed for predefined type resolution
// so that assembly-level attribute constructor arguments can be bound)
Expand Down
2 changes: 1 addition & 1 deletion src/Mocha/test/Mocha.Mediator.Tests/AddHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void AddHandler_Should_Throw_When_TypeIsNotHandler()
// Act & Assert - validation is deferred to Build() time, which happens
// when MediatorRuntime is first resolved (triggered by IMediator resolution).
Assert.Throws<InvalidOperationException>(
() => sp.GetRequiredService<IMediator>());
sp.GetRequiredService<IMediator>);
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions src/Mocha/test/Mocha.Mediator.Tests/ContextPoolingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public async Task SendAsync_Should_IsolateContextPerThread_When_DispatchedConcur
// Synchronize all threads to maximize contention
barrier.SignalAndWait();

var result = await mediator.SendAsync<string>(
var result = await mediator.SendAsync(
new PoolTestCommandWithResponse($"thread-{index}"));
capturedMessages[index] = result;
}, TaskCreationOptions.LongRunning).Unwrap();
Expand Down Expand Up @@ -133,7 +133,7 @@ public async Task SendAsync_Should_PopulateContextFields_When_PipelineExecutes()
var command = new ContextCaptureCommand("payload");

// Act
await mediator.SendAsync<string>(command, cts.Token);
await mediator.SendAsync(command, cts.Token);

// Assert: the capturing middleware recorded the correct context fields.
Assert.Same(scope.ServiceProvider, ContextCapture.CapturedServices);
Expand Down
Loading
Loading