Skip to content

Added support for .net 8 - DTF Service Fabric #1205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
29 changes: 17 additions & 12 deletions Directory.Packages.props
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a bunch of package changes here that will impact all projects in this repo. Have you verified what the impact to other packages are? Keep in mind we cannot have any major version revs of any transitive dependency. This is considered a breaking change to customers and we would need to also major version rev.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the other project's target .net8. All projects continue to be on the same version. Updated the Packages.props to a more understandable structure.

Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,29 @@
<PackageVersion Include="Azure.Storage.Queues" Version="12.20.0" />
<PackageVersion Include="Castle.Core" Version="5.0.0" />
<PackageVersion Include="ImpromptuInterface" Version="6.2.2" Condition="'$(TargetFramework)' == 'net462' OR '$(TargetFramework)' == 'net472'" />
<PackageVersion Include="ImpromptuInterface" Version="7.0.1" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
<PackageVersion Include="ImpromptuInterface" Version="7.0.1" Condition="'$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'net8.0'" />
<PackageVersion Include="Microsoft.ApplicationInsights" Version="2.21.0" />
<PackageVersion Include="Microsoft.AspNet.WebApi.OwinSelfHost" Version="5.2.6" />
<PackageVersion Include="Microsoft.AspNet.WebApi.OwinSelfHost" Version="5.2.6" Condition="'$(TargetFramework)' == 'net462' OR '$(TargetFramework)' == 'net472'" />
<PackageVersion Include="Microsoft.AspNet.WebApi.Client" Version="5.2.6" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc" Version="2.3.0" Condition="'$(TargetFramework)' == 'net8.0'"/>
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.15" Condition="'$(TargetFramework)' == 'net8.0'" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
<PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
<PackageVersion Include="Microsoft.Data.Services.Client" Version="5.8.5" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="2.1.1" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="2.1.1" Condition="'$(TargetFramework)' == 'net462' OR '$(TargetFramework)' == 'net472'"/>
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" Condition="'$(TargetFramework)' == 'net8.0'"/>
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
<PackageVersion Include="Microsoft.ServiceFabric" Version="6.4.617" />
<PackageVersion Include="Microsoft.ServiceFabric.Data" Version="3.3.617" />
<PackageVersion Include="Microsoft.ServiceFabric.Services" Version="3.3.617" />
<PackageVersion Include="Microsoft.ServiceFabric" Version="6.4.617" Condition="'$(TargetFramework)' == 'net462' OR '$(TargetFramework)' == 'net472'"/>
<PackageVersion Include="Microsoft.ServiceFabric.Data" Version="3.3.617" Condition="'$(TargetFramework)' == 'net462' OR '$(TargetFramework)' == 'net472'"/>
<PackageVersion Include="Microsoft.ServiceFabric.Services" Version="3.3.617" Condition="'$(TargetFramework)' == 'net462' OR '$(TargetFramework)' == 'net472'"/>
<PackageVersion Include="Microsoft.ServiceFabric.AspNetCore.Kestrel" Version="3.3.617" Condition="'$(TargetFramework)' == 'net462' OR '$(TargetFramework)' == 'net472'"/>
<PackageVersion Include="Microsoft.ServiceFabric" Version="10.1.2175" Condition="'$(TargetFramework)' == 'net8.0'"/>
<PackageVersion Include="Microsoft.ServiceFabric.Data" Version="7.1.2175" Condition="'$(TargetFramework)' == 'net8.0'"/>
<PackageVersion Include="Microsoft.ServiceFabric.Services" Version="7.1.2175" Condition="'$(TargetFramework)' == 'net8.0'"/>
<PackageVersion Include="Microsoft.ServiceFabric.AspNetCore.Kestrel" Version="7.1.2175" Condition="'$(TargetFramework)' == 'net8.0'"/>
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.0.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.1" />
<PackageVersion Include="System.Collections.Immutable" Version="1.2.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="System.Collections.Immutable" Version="1.3.1" />
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="6.0.1" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="System.Reactive.Compatibility" Version="4.4.1" />
Expand Down Expand Up @@ -76,7 +85,6 @@

<!-- Test dependencies with net472-->
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<PackageVersion Include="Microsoft.AspNet.WebApi.Client" Version="5.2.6" />
<PackageVersion Include="Microsoft.AspNet.WebApi.Owin" Version="5.2.6" />
<PackageVersion Include="Microsoft.Owin.Hosting" Version="4.0.0" />
</ItemGroup>
Expand Down Expand Up @@ -106,9 +114,6 @@

<!-- Samples dependencies with net8.0-->
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
</ItemGroup>

<!-- Samples dependencies with net462-->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),DurableTask.sln))\tools\DurableTask.props" />

<PropertyGroup>
<TargetFrameworks>net462;net472</TargetFrameworks>
<TargetFrameworks>net8.0;net462;net472</TargetFrameworks>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look fairly extensive, especially adding a new TFM. Have you evaluated what version change needs to happen? if there are any breaking changes (even revving transitive dependencies across major versions), then this package will need a major version rev as well.

<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PackageId>Microsoft.Azure.DurableTask.AzureServiceFabric</PackageId>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand All @@ -14,29 +15,46 @@
<Authors>Microsoft</Authors>
<Platforms>AnyCPU;x64</Platforms>
<NoWarn>$(NoWarn);NU5104</NoWarn>
</PropertyGroup>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<Reference Include="System.Web" />
<PackageReference Include="Microsoft.AspNet.WebApi.OwinSelfHost" />
<Compile Include="Service\.net462\**" />
<Compile Remove="Service\.net8\**" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<Reference Include="System.Web" />
<PackageReference Include="Microsoft.AspNet.WebApi.OwinSelfHost" />
<Compile Include="Service\.net462\**" />
<Compile Remove="Service\.net8\**" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<!-- Restoring packages for netstandard2.0 causes warnings. As warnings are treated as errors, compilation will fail. -->
<!-- Once the packages support netstandard2.0, this project will support netstandard2.0. -->
<PackageReference Include="Newtonsoft.Json" />
<Compile Remove="Service\.net462\**" />
<Compile Remove="Service\.net8\**" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" />
<Compile Remove="Service\.net462\**" />
<Compile Include="Service\.net8\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="ImpromptuInterface" />
<PackageReference Include="Microsoft.AspNet.WebApi.OwinSelfHost" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.ServiceFabric" />
<PackageReference Include="Microsoft.ServiceFabric.Data" />
<PackageReference Include="Microsoft.ServiceFabric.Services" />
<PackageReference Include="Microsoft.ServiceFabric" />
<PackageReference Include="Microsoft.ServiceFabric.AspNetCore.Kestrel" />
<PackageReference Include="System.Collections.Immutable" />
</ItemGroup>

Expand All @@ -50,4 +68,5 @@
<PackagePath>content/SBOM</PackagePath>
</Content>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public Task<long> GeneratePartitionHashCodeAsync(string value, CancellationToken
long hashCode = 0;
if (!string.IsNullOrEmpty(value))
{
using (var sha256 = SHA256Managed.Create())
using (var sha256 = SHA256.Create())
{
var bytes = Encoding.UTF8.GetBytes(value);
var hash = sha256.ComputeHash(bytes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@ namespace DurableTask.AzureServiceFabric.Remote
using System.Threading;
using System.Threading.Tasks;
using System.Web;

using DurableTask.Core;
using DurableTask.Core.Exceptions;
using DurableTask.AzureServiceFabric.Exceptions;
using DurableTask.AzureServiceFabric.Models;

using DurableTask.Core;
using DurableTask.Core.Exceptions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Web.Http.Results;

/// <summary>
/// Allows to interact with a remote IOrchestrationServiceClient
Expand Down Expand Up @@ -154,7 +151,11 @@ public async Task<IList<OrchestrationState>> GetOrchestrationStateAsync(string i
{
instanceId.EnsureValidInstanceId();

#if NETFRAMEWORK
var fragment = $"{this.GetOrchestrationFragment(instanceId)}?allExecutions={allExecutions}";
#else
var fragment = $"{this.GetOrchestrationFragmentAll(instanceId)}?allExecutions={allExecutions}";

var stateString = await this.GetStringResponseAsync(instanceId, fragment, CancellationToken.None);
var states = JsonConvert.DeserializeObject<IList<OrchestrationState>>(stateString);
return states;
Expand Down Expand Up @@ -278,6 +279,8 @@ public async Task<OrchestrationState> WaitForOrchestrationAsync(string instanceI

private string GetOrchestrationFragment(string orchestrationId) => $"orchestrations/{orchestrationId}";

private string GetOrchestrationFragmentAll(string orchestrationId) => $"orchestrationsAll/{orchestrationId}";

private string GetMessageFragment() => "messages";

private string GetMessageFragment(long messageId) => $"messages/{messageId}";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// ----------------------------------------------------------------------------------
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

namespace DurableTask.AzureServiceFabric.Service
{
using System;
using System.Fabric;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Threading.Tasks;

using DurableTask.Core;
using DurableTask.AzureServiceFabric;
using DurableTask.AzureServiceFabric.Tracing;

using Microsoft.ServiceFabric.Services.Communication.Runtime;
using Microsoft.ServiceFabric.Services.Runtime;

/// <inheritdoc />
public sealed class TaskHubProxyListener : TaskHubProxyListenerBase
{
/// <summary>
/// Creates instance of <see cref="TaskHubProxyListener"/>
/// </summary>
/// <param name="context">stateful service context</param>
/// <param name="fabricOrchestrationProviderSettings">instance of <see cref="FabricOrchestrationProviderSettings"/></param>
/// <param name="registerOrchestrations">Delegate invoked before starting the worker.</param>
[Obsolete]
public TaskHubProxyListener(StatefulServiceContext context,
FabricOrchestrationProviderSettings fabricOrchestrationProviderSettings,
RegisterOrchestrations registerOrchestrations) : base(fabricOrchestrationProviderSettings, registerOrchestrations)
{
}

/// <summary>
/// Creates instance of <see cref="TaskHubProxyListener"/>
/// </summary>
/// <param name="fabricOrchestrationProviderSettings">instance of <see cref="FabricOrchestrationProviderSettings"/></param>
/// <param name="registerOrchestrations">Delegate invoked before starting the worker.</param>
/// <param name="enableHttps">Whether to enable https or http</param>
public TaskHubProxyListener(FabricOrchestrationProviderSettings fabricOrchestrationProviderSettings,
RegisterOrchestrations registerOrchestrations,
bool enableHttps = true): base(fabricOrchestrationProviderSettings, registerOrchestrations, enableHttps)
{
}

/// <summary>
/// Creates instance of <see cref="TaskHubProxyListener"/>
/// </summary>
/// <remarks>
/// Use this constructor when there is a need to access <see cref="TaskHubClient"/>
/// when registering orchestration artifacts with <see cref="TaskHubWorker"/>
/// </remarks>
/// <param name="fabricOrchestrationProviderSettings">instance of <see cref="FabricOrchestrationProviderSettings"/></param>
/// <param name="registerOrchestrations2">Delegate invoked before starting the worker.</param>
/// <param name="enableHttps">Whether to enable https or http</param>
public TaskHubProxyListener(FabricOrchestrationProviderSettings fabricOrchestrationProviderSettings,
RegisterOrchestrations2 registerOrchestrations2,
bool enableHttps = true) : base(fabricOrchestrationProviderSettings, registerOrchestrations2, enableHttps)
{
}

/// <inheritdoc />
public override ServiceReplicaListener CreateServiceReplicaListener()
{
return new ServiceReplicaListener(context =>
{
var serviceEndpoint = context.CodePackageActivationContext.GetEndpoint(Constants.TaskHubProxyListenerEndpointName);
string ipAddress = context.NodeContext.IPAddressOrFQDN;
#if DEBUG
IPHostEntry entry = Dns.GetHostEntry(ipAddress);
IPAddress ipv4Address = entry.AddressList.FirstOrDefault(
address => (address.AddressFamily == AddressFamily.InterNetwork) && (!IPAddress.IsLoopback(address)));
ipAddress = ipv4Address.ToString();
#endif

EnsureFabricOrchestrationProviderIsInitialized();
string protocol = this.enableHttps ? "https" : "http";
string listeningAddress = string.Format(CultureInfo.InvariantCulture, "{0}://{1}:{2}/{3}/dtfx/", protocol, ipAddress, serviceEndpoint.Port, context.PartitionId);

return new OwinCommunicationListener(new Startup(listeningAddress, this.fabricOrchestrationProvider));
}, Constants.TaskHubProxyServiceName);
}
}
}
Loading