Skip to content

Commit

Permalink
dismiss fear of type lookup failing
Browse files Browse the repository at this point in the history
  • Loading branch information
mookid8000 committed May 21, 2024
1 parent 4dc42d9 commit dcfb862
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ClassLibraryWithCustomName/ClassLibraryWithCustomName.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>CompanyName.ClassLibraryWithCustomName</AssemblyName>
</PropertyGroup>

</Project>
3 changes: 3 additions & 0 deletions ClassLibraryWithCustomName/MyFavoriteMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace ClassLibraryWithCustomName;

public record MyFavoriteMessage(Guid RecognizableValue);
1 change: 1 addition & 0 deletions Rebus.Tests/Rebus.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<LangVersion>12</LangVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ClassLibraryWithCustomName\ClassLibraryWithCustomName.csproj" />
<ProjectReference Include="..\Rebus\Rebus.csproj" />
</ItemGroup>
<ItemGroup>
Expand Down
17 changes: 17 additions & 0 deletions Rebus.Tests/Serialization/TestJsonSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using ClassLibraryWithCustomName;
using Newtonsoft.Json;
using NUnit.Framework;
using Rebus.Extensions;
Expand All @@ -26,6 +27,22 @@ protected override void SetUp()
_serializer = new JsonSerializer(new SimpleAssemblyQualifiedMessageTypeNameConvention());
}

[Test]
public async Task VerifyMessageFromAssemblyWithCustomizedNameCanBeRoundtripped()
{
var recognizableValue = Guid.NewGuid();

var body = new MyFavoriteMessage(RecognizableValue: recognizableValue);
var message = new Message(new(), body);

var transportMessage = await _serializer.Serialize(message);
Console.WriteLine($"{Headers.Type}: {transportMessage.Headers[Headers.Type]}");
var roundtrippedMessage = await _serializer.Deserialize(transportMessage);
var roundtrippedBody = (MyFavoriteMessage)roundtrippedMessage.Body;

Assert.That(roundtrippedBody.RecognizableValue, Is.EqualTo(recognizableValue));
}

/*
Initial:
Made 23133 iterations in 00:00:01
Expand Down
17 changes: 17 additions & 0 deletions Rebus.Tests/Serialization/TestSystemTextJsonSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using ClassLibraryWithCustomName;
using Newtonsoft.Json;
using NUnit.Framework;
using Rebus.Extensions;
Expand All @@ -27,6 +28,22 @@ protected override void SetUp()
_serializer = new SystemTextJsonSerializer(new SimpleAssemblyQualifiedMessageTypeNameConvention());
}

[Test]
public async Task VerifyMessageFromAssemblyWithCustomizedNameCanBeRoundtripped()
{
var recognizableValue = Guid.NewGuid();

var body = new MyFavoriteMessage(RecognizableValue: recognizableValue);
var message = new Message(new(), body);

var transportMessage = await _serializer.Serialize(message);
Console.WriteLine($"{Headers.Type}: {transportMessage.Headers[Headers.Type]}");
var roundtrippedMessage = await _serializer.Deserialize(transportMessage);
var roundtrippedBody = (MyFavoriteMessage)roundtrippedMessage.Body;

Assert.That(roundtrippedBody.RecognizableValue, Is.EqualTo(recognizableValue));
}

/*
Initial:
Made 23133 iterations in 00:00:01
Expand Down
7 changes: 7 additions & 0 deletions Rebus8.sln
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{EAB8CED5
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Rebus", "Rebus\Rebus.csproj", "{319215F6-B626-4271-8EDA-E31B876F65C0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibraryWithCustomName", "ClassLibraryWithCustomName\ClassLibraryWithCustomName.csproj", "{49ACBC0A-7B66-4BB7-A271-A20E2EA0D75A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -45,6 +47,10 @@ Global
{319215F6-B626-4271-8EDA-E31B876F65C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{319215F6-B626-4271-8EDA-E31B876F65C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{319215F6-B626-4271-8EDA-E31B876F65C0}.Release|Any CPU.Build.0 = Release|Any CPU
{49ACBC0A-7B66-4BB7-A271-A20E2EA0D75A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{49ACBC0A-7B66-4BB7-A271-A20E2EA0D75A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{49ACBC0A-7B66-4BB7-A271-A20E2EA0D75A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{49ACBC0A-7B66-4BB7-A271-A20E2EA0D75A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -53,6 +59,7 @@ Global
{959C65AB-D21A-4582-BC4F-06D1425FF274} = {EAB8CED5-4383-48F3-AB54-E57278CDD93B}
{F1CFF884-8176-48C2-9D51-E9DAAC8E11FB} = {63AB64A3-A453-4663-BDB6-530F2136609D}
{319215F6-B626-4271-8EDA-E31B876F65C0} = {63AB64A3-A453-4663-BDB6-530F2136609D}
{49ACBC0A-7B66-4BB7-A271-A20E2EA0D75A} = {EAB8CED5-4383-48F3-AB54-E57278CDD93B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FEDAD2E7-01F9-45C3-AA52-85FE700C676B}
Expand Down

0 comments on commit dcfb862

Please sign in to comment.