Skip to content

Commit

Permalink
Prepare repo for .NET 8 (#6810)
Browse files Browse the repository at this point in the history
* Update project files

* Remove ifdefs

* Update Analyzer to use latest 17.7 package

* Fix obsolete errors

* Fix error

* Add workaround for testhost packaging error

* Bump major version

* Remove v8 obsoletes

* Move v9 obsoletes

* Update to .NET 8 dependencies

* Update Microsoft.NET.Test.Sdk

* Update workflows

* Remove init.ps1

* Remove references to obsolete stuff

* Use new di registration API

* Remove all usages of old DI registration API

* Remove asserts for now obsoleted address access methods

* IMessageCreator is no longer available in DI

* Add todo

* Add todo about TransactionManager.ImplicitDistributedTransactions

* Make sure IMessageCreator is registered

* Go back to IMessageCreator since that is what's being tested

* Revert test

* Properly register installers

* Register interfaces

* Approve DI changes

* Revert auto property change in DataBusProperty

* Remove obsolete call to InstanceSpecificQueue

* Add windows guard to dtc tests

* Clean up MessageDrivenSubscriptions comment and remove reference

* Remove unused UnitOfWork stuff

* Remove unneeded tests

* Clean up AddAuditData references

* Extract interface registrations to helper

* Fix registration bug

* Fix feature dependency

* Make relevant container tests use new helper

* Complete obsoletion of notifications

* Fix ordering of tx scope

* Update approval files for acceptance tests

* Remove exception test with obsolete constructor requirements

* Restore NonDurableMessage header value

* Update PreObsoleteAttribute usage

* Clean up TransportDefinition.ToTransportAddress

* Tweak Notifications obsoletes

* Rename internal class to fix test

* Update approval files

* Remove binding redirect stuff from AssemblyScanner error messages

* Update PreObsolete issue link

* Update PreObsoleteAttribute XML comment

* Get rid of AddWithInterfaces

---------

Co-authored-by: Andreas Öhlund <[email protected]>
Co-authored-by: kentdr <[email protected]>
  • Loading branch information
3 people authored Aug 17, 2023
1 parent 76c1280 commit f496bbd
Show file tree
Hide file tree
Showing 116 changed files with 572 additions and 5,187 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
strategy:
matrix:
include:
- os: windows-2019
- os: windows-2022
name: Windows
- os: ubuntu-20.04
- os: ubuntu-22.04
name: Linux
fail-fast: false
steps:
Expand All @@ -28,9 +28,8 @@ jobs:
- name: Setup .NET SDK
uses: actions/[email protected]
with:
dotnet-version: |
7.0.x
6.0.x
dotnet-version: 8.0.x
dotnet-quality: 'preview'
- name: Build
run: dotnet build src --configuration Release
- name: Upload packages
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
DOTNET_NOLOGO: true
jobs:
release:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/[email protected]
Expand All @@ -17,7 +17,8 @@ jobs:
- name: Setup .NET SDK
uses: actions/[email protected]
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
dotnet-quality: 'preview'
- name: Build
run: dotnet build src --configuration Release
- name: Sign NuGet packages
Expand Down
2 changes: 1 addition & 1 deletion src/Custom.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<PropertyGroup>
<MinVerMinimumMajorMinor>8.1</MinVerMinimumMajorMinor>
<MinVerMinimumMajorMinor>9.0</MinVerMinimumMajorMinor>
<MinVerAutoIncrement>minor</MinVerAutoIncrement>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ class AcceptanceTestingSubscriptionPersistence : Feature
{
public AcceptanceTestingSubscriptionPersistence()
{
#pragma warning disable CS0618
DependsOn<MessageDrivenSubscriptions>();
#pragma warning restore CS0618
DependsOn("NServiceBus.Features.MessageDrivenSubscriptions");
}

protected internal override void Setup(FeatureConfigurationContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using AcceptanceTesting;
Expand All @@ -27,34 +26,10 @@ public override async Task<TransportInfrastructure> Initialize(HostSettings host
return infrastructure;
}

[Obsolete("Obsolete marker to make the code compile", false)]
[Obsolete("This should be removed when TransportDefinition.ToTransportAddress is removed in v10.", true)]
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member
public override string ToTransportAddress(QueueAddress address)
public override string ToTransportAddress(QueueAddress address) => throw new NotImplementedException();
#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member
{
var baseAddress = address.BaseAddress;
ThrowForBadPath(baseAddress, "endpoint name");

var discriminator = address.Discriminator;

if (!string.IsNullOrEmpty(discriminator))
{
ThrowForBadPath(discriminator, "endpoint discriminator");

baseAddress += "-" + discriminator;
}

var qualifier = address.Qualifier;

if (!string.IsNullOrEmpty(qualifier))
{
ThrowForBadPath(qualifier, "address qualifier");

baseAddress += "-" + qualifier;
}

return baseAddress;
}

public override IReadOnlyCollection<TransportTransactionMode> GetSupportedTransactionModes()
{
Expand All @@ -67,6 +42,7 @@ public override IReadOnlyCollection<TransportTransactionMode> GetSupportedTransa
}

string storageLocation;

public string StorageLocation
{
get => storageLocation;
Expand All @@ -77,22 +53,5 @@ public string StorageLocation
storageLocation = value;
}
}

static void ThrowForBadPath(string value, string valueName)
{
var invalidPathChars = Path.GetInvalidPathChars();

if (string.IsNullOrEmpty(value))
{
return;
}

if (value.IndexOfAny(invalidPathChars) < 0)
{
return;
}

throw new Exception($"The value for '{valueName}' has illegal path characters. Provided value: {value}. Must not contain any of {string.Join(", ", invalidPathChars)}.");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\NServiceBus.snk</AssemblyOriginatorKeyFile>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<LangVersion>10.0</LangVersion>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\NServiceBus.Core\NServiceBus.Core.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<Reference Include="System.Transactions" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="[3.13.3, 4.0.0)" />
<PackageReference Include="Particular.Packaging" Version="3.0.0" PrivateAssets="All" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace NServiceBus.AcceptanceTesting
{
using System;
using System.Runtime.Serialization;

/// <summary>
/// A dummy exception to be used in acceptance tests for easier differentiation from real exceptions.
Expand All @@ -19,9 +18,5 @@ public SimulatedException(string message) : base(message)
public SimulatedException(string message, Exception innerException) : base(message, innerException)
{
}

protected SimulatedException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ NServiceBus.Unicast.Subscriptions.MessageDrivenSubscriptions.ISubscriptionStorag
----------- Public registrations not used by Core -----------
NServiceBus.CriticalError - Singleton
NServiceBus.Hosting.HostInformation - Singleton
NServiceBus.IHandleMessages`1[[NServiceBus.AcceptanceTests.Core.DependencyInjection.When_endpoint_is_warmed_up+SomeMessage, NServiceBus.AcceptanceTests, Version=8.0.0.0, Culture=neutral, PublicKeyToken=null]] - Scoped
NServiceBus.IMessageCreator - Singleton
NServiceBus.MessageInterfaces.IMessageMapper - Singleton
NServiceBus.Notifications - Singleton
NServiceBus.Persistence.ISynchronizedStorageSession - Scoped
NServiceBus.Pipeline.IBehavior - Transient
NServiceBus.Pipeline.IBehavior`2[[NServiceBus.Pipeline.IIncomingLogicalMessageContext, NServiceBus.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c],[NServiceBus.Pipeline.IIncomingLogicalMessageContext, NServiceBus.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c]] - Transient
NServiceBus.Pipeline.IBehavior`2[[NServiceBus.Pipeline.IIncomingPhysicalMessageContext, NServiceBus.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c],[NServiceBus.Pipeline.IIncomingPhysicalMessageContext, NServiceBus.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c]] - Transient
NServiceBus.Pipeline.LogicalMessageFactory - Singleton
NServiceBus.Settings.IReadOnlySettings - Singleton
NServiceBus.Transport.ISubscriptionManager - Singleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,11 @@
(IIncomingPhysicalMessageContext context3) => ProcessingStatisticsBehavior.Invoke(context3,
(IIncomingPhysicalMessageContext context4) => MutateIncomingTransportMessageBehavior.Invoke(context4,
(IIncomingPhysicalMessageContext context5) => SubscriptionReceiverBehavior.Invoke(context5,
(IIncomingPhysicalMessageContext context6) => UnitOfWorkBehavior.Invoke(context6,
(IIncomingPhysicalMessageContext context7) => DeserializeMessageConnector.Invoke(context7,
(IIncomingLogicalMessageContext context8) => MutateIncomingMessageBehavior.Invoke(context8,
(IIncomingLogicalMessageContext context9) => InferredMessageTypeEnricherBehavior.Invoke(context9,
(IIncomingLogicalMessageContext context10) => LoadHandlersConnector.Invoke(context10,
(IInvokeHandlerContext context11) => InvokeHandlerTerminator.Invoke(context11))
(IIncomingPhysicalMessageContext context6) => DeserializeMessageConnector.Invoke(context6,
(IIncomingLogicalMessageContext context7) => MutateIncomingMessageBehavior.Invoke(context7,
(IIncomingLogicalMessageContext context8) => InferredMessageTypeEnricherBehavior.Invoke(context8,
(IIncomingLogicalMessageContext context9) => LoadHandlersConnector.Invoke(context9,
(IInvokeHandlerContext context10) => InvokeHandlerTerminator.Invoke(context10))

(IRecoverabilityContext context0) => CaptureRecoverabilityActionBehavior.Invoke(context0,
(IRecoverabilityContext context1) => RecoverabilityRoutingConnector.Invoke(context1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,10 @@ public override Task<TransportInfrastructure> Initialize(HostSettings hostSettin
return Task.FromResult<TransportInfrastructure>(infrastructure);
}

[Obsolete("Obsolete marker to make the code compile", false)]
[Obsolete("This should be removed when TransportDefinition.ToTransportAddress is removed in v10.", true)]
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member
public override string ToTransportAddress(QueueAddress address)
public override string ToTransportAddress(QueueAddress address) => throw new NotImplementedException();
#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member
{
return new LearningTransport().ToTransportAddress(address);
}

public override IReadOnlyCollection<TransportTransactionMode> GetSupportedTransactionModes()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,10 @@ public override Task<TransportInfrastructure> Initialize(HostSettings hostSettin
return Task.FromResult<TransportInfrastructure>(new FakeTransportInfrastructure(receivers));
}

[Obsolete("Obsolete marker to make the code compile", false)]
[Obsolete("This should be removed when TransportDefinition.ToTransportAddress is removed in v10.", true)]
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member
public override string ToTransportAddress(QueueAddress address)
public override string ToTransportAddress(QueueAddress address) => throw new NotImplementedException();
#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member
{
return address.ToString();
}

public override IReadOnlyCollection<TransportTransactionMode> GetSupportedTransactionModes()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ public interface IMyReply : IMessage
{
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,10 @@ public Endpoint()

public class StartMessageHandler : IHandleMessages<StartMessage>
{
public StartMessageHandler(IMessageCreator messageCreator)
{
this.messageCreator = messageCreator;
}

public Task Handle(StartMessage message, IMessageHandlerContext context)
{
var interfaceMessage = messageCreator.CreateInstance<IMyMessage>();
return context.Send(interfaceMessage);
return context.Send<IMyMessage>(_ => { });
}

IMessageCreator messageCreator;
}

public class MyMessageHandler : IHandleMessages<IMyMessage>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
namespace NServiceBus.AcceptanceTests.Core.TransportSeam
{
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AcceptanceTesting;
using EndpointTemplates;
using Features;
using NServiceBus.Configuration.AdvancedExtensibility;
using NServiceBus.Transport;
using NUnit.Framework;

Expand All @@ -25,9 +23,7 @@ public async Task Should_provide_access_to_addresses_and_address_resolution()

Assert.AreEqual("SomeAddress", context.ResolvedAddress);
Assert.AreEqual(endpointName, context.ReceiveAddresses.MainReceiveAddress);
Assert.AreEqual(context.LocalAddress, context.ReceiveAddresses.MainReceiveAddress);
Assert.AreEqual(endpointName + "-MyInstance", context.ReceiveAddresses.InstanceReceiveAddress);
Assert.AreEqual(context.InstanceSpecificQueue, context.ReceiveAddresses.InstanceReceiveAddress);
Assert.AreEqual("MySatellite", context.ReceiveAddresses.SatelliteReceiveAddresses.Single());
Assert.AreEqual(endpointName, context.LocalQueueAddress.ToString());
Assert.AreEqual(endpointName + "-MyInstance", context.InstanceSpecificQueueAddress.ToString());
Expand All @@ -37,8 +33,6 @@ class Context : ScenarioContext
{
public string ResolvedAddress { get; set; }
public ReceiveAddresses ReceiveAddresses { get; set; }
public string LocalAddress { get; set; }
public string InstanceSpecificQueue { get; set; }
public QueueAddress LocalQueueAddress { get; set; }
public QueueAddress InstanceSpecificQueueAddress { get; set; }
}
Expand All @@ -49,13 +43,6 @@ public Endpoint()
{
EndpointSetup<DefaultServer>(c =>
{
#pragma warning disable IDE0079
#pragma warning disable CS0618
Assert.Throws<InvalidOperationException>(() => c.GetSettings().LocalAddress(), "Should throw since the endpoint isn't configured yet");
Assert.Throws<InvalidOperationException>(() => c.GetSettings().InstanceSpecificQueue(), "Should throw since the endpoint isn't configured yet");
#pragma warning restore CS0618
#pragma warning restore IDE0079
c.EnableFeature<FeatureAccessingAddressing>();
c.MakeInstanceUniquelyAddressable("MyInstance");
});
Expand All @@ -67,13 +54,6 @@ protected override void Setup(FeatureConfigurationContext context)
{
var testContext = (Context)context.Settings.Get<ScenarioContext>();

#pragma warning disable IDE0079
#pragma warning disable CS0618
testContext.LocalAddress = context.Settings.LocalAddress();
testContext.InstanceSpecificQueue = context.Settings.InstanceSpecificQueue();
#pragma warning restore CS0618
#pragma warning restore IDE0079

testContext.LocalQueueAddress = context.LocalQueueAddress();
testContext.InstanceSpecificQueueAddress = context.InstanceSpecificQueueAddress();

Expand Down
Loading

0 comments on commit f496bbd

Please sign in to comment.