Skip to content

Commit

Permalink
refs
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Feb 12, 2025
1 parent 0cbbc69 commit 9b37822
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 24 deletions.
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public class MessageHandler1 :
IWantToRunAfter<MessageHandler3>
{
```
<sup><a href='/src/Tests/Snippets/MessageHandler1.cs#L3-L8' title='Snippet source file'>snippet source</a> | <a href='#snippet-express-order1-1' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Tests/Snippets/MessageHandler1.cs#L1-L6' title='Snippet source file'>snippet source</a> | <a href='#snippet-express-order1-1' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -118,7 +118,7 @@ public class MessageHandler2 :
IWantToRunAfter<MessageHandler1>
{
```
<sup><a href='/src/Tests/Snippets/MessageHandler2.cs#L3-L8' title='Snippet source file'>snippet source</a> | <a href='#snippet-express-order2-1' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Tests/Snippets/MessageHandler2.cs#L1-L6' title='Snippet source file'>snippet source</a> | <a href='#snippet-express-order2-1' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down Expand Up @@ -166,7 +166,7 @@ public class MessageHandler1 :
IWantToRunAfter<MessageHandler3>
{
```
<sup><a href='/src/Tests/Snippets/MessageHandler1.cs#L3-L8' title='Snippet source file'>snippet source</a> | <a href='#snippet-express-order1-1' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Tests/Snippets/MessageHandler1.cs#L1-L6' title='Snippet source file'>snippet source</a> | <a href='#snippet-express-order1-1' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -188,7 +188,7 @@ public class MessageHandler2 :
IWantToRunAfter<MessageHandler1>
{
```
<sup><a href='/src/Tests/Snippets/MessageHandler2.cs#L3-L8' title='Snippet source file'>snippet source</a> | <a href='#snippet-express-order2-1' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Tests/Snippets/MessageHandler2.cs#L1-L6' title='Snippet source file'>snippet source</a> | <a href='#snippet-express-order2-1' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down
1 change: 1 addition & 0 deletions src/HandlerOrdering.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
appveyor.yml = appveyor.yml
Directory.Build.props = Directory.Build.props
global.json = global.json
EndProjectSection
EndProject
Global
Expand Down
4 changes: 2 additions & 2 deletions src/HandlerOrdering/NServiceBus.HandlerOrdering.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NServiceBus" Version="8.2.4" />
<PackageReference Include="NServiceBus" Version="9.2.5" />
<PackageReference Include="ProjectDefaults" Version="1.0.147" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" Condition="$(Configuration) == 'Release'" />
</ItemGroup>
Expand Down
7 changes: 6 additions & 1 deletion src/HandlerOrdering/OrderHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public void Customize(EndpointConfiguration configuration)
}
}

public void ApplyInterfaceHandlerOrdering(EndpointConfiguration configuration)
static void ApplyInterfaceHandlerOrdering(EndpointConfiguration configuration)
{
var handlerDependencies = GetHandlerDependencies(configuration);
var sorted = new TypeSorter(handlerDependencies).Sorted;
Expand All @@ -24,6 +24,7 @@ static Dictionary<Type, List<Type>> GetHandlerDependencies(EndpointConfiguration
{
throw new($"Could not extract 'scannedTypes' field from {nameof(EndpointConfiguration)}. Raise an issue here https://github.com/NServiceBusExtensions/NServiceBus.HandlerOrdering/issues/new");
}

var types = (List<Type>) field.GetValue(configuration)!;
return GetHandlerDependencies(types);
}
Expand All @@ -40,17 +41,21 @@ internal static Dictionary<Type, List<Type>> GetHandlerDependencies(List<Type> t
{
continue;
}

if (face.GetGenericTypeDefinition() != typeof(IWantToRunAfter<>))
{
continue;
}

if (!dictionary.TryGetValue(type, out var dependencies))
{
dictionary[type] = dependencies = new();
}

dependencies.Add(face.GenericTypeArguments.First());
}
}

return dictionary;
}
}
4 changes: 2 additions & 2 deletions src/Sample/Sample.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<OutputType>Exe</OutputType>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NServiceBus" Version="8.2.4" />
<PackageReference Include="NServiceBus" Version="9.2.5" />
<ProjectReference Include="..\HandlerOrdering\NServiceBus.HandlerOrdering.csproj" />
</ItemGroup>
</Project>
4 changes: 1 addition & 3 deletions src/Tests/Snippets/MessageHandler1.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using NServiceBus;

#region express-order1
#region express-order1
public class MessageHandler1 :
IHandleMessages<MyMessage>,
IWantToRunAfter<MessageHandler3>
Expand Down
4 changes: 1 addition & 3 deletions src/Tests/Snippets/MessageHandler2.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using NServiceBus;

#region express-order2
#region express-order2
public class MessageHandler2 :
IHandleMessages<MyMessage>,
IWantToRunAfter<MessageHandler1>
Expand Down
4 changes: 1 addition & 3 deletions src/Tests/Snippets/MessageHandler3.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using NServiceBus;

public class MessageHandler3 :
public class MessageHandler3 :
IHandleMessages<MyMessage>
{
public Task Handle(MyMessage message, IMessageHandlerContext context) =>
Expand Down
4 changes: 1 addition & 3 deletions src/Tests/Snippets/MyMessage.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using NServiceBus;

public class MyMessage :
public class MyMessage :
IMessage
{
public Guid Id { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Snippets/Usage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NServiceBus;
#pragma warning disable IDE0021

class Usage
{
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2" PrivateAssets="all" />
Expand Down
2 changes: 1 addition & 1 deletion src/global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.101",
"version": "9.0.200",
"allowPrerelease": true,
"rollForward": "latestFeature"
}
Expand Down

0 comments on commit 9b37822

Please sign in to comment.