Skip to content
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

Add .net9 transitive dependencies #2852

Merged
merged 9 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
4 changes: 2 additions & 2 deletions src/DotNetWorker.Core/Converters/JsonPocoConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ private async Task<ConversionResult> GetConversionResultFromDeserialization(byte
}
finally
{
if (stream != null)
if (stream != null)
{
#if NET8_0_OR_GREATER
#if NET6_0_OR_GREATER

await ((IAsyncDisposable)stream).DisposeAsync();
#else
Expand Down
2 changes: 1 addition & 1 deletion src/DotNetWorker.Core/Converters/MemoryConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public ValueTask<ConversionResult> ConvertAsync(ConverterContext context)

if (context.TargetType.IsAssignableFrom(typeof(string)))
{
#if NET8_0_OR_GREATER
#if NET6_0_OR_GREATER
var target = Encoding.UTF8.GetString(sourceMemory.Span);
#else
var target = Encoding.UTF8.GetString(sourceMemory.Span.ToArray());
Expand Down
22 changes: 12 additions & 10 deletions src/DotNetWorker.Core/DotNetWorker.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>net8.0;net9.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0;net9.0;netstandard2.0</TargetFrameworks>
<PackageId>Microsoft.Azure.Functions.Worker.Core</PackageId>
<Description>This library provides the core functionality to build an Azure Functions .NET Worker, adding support for the isolated, out-of-process execution model.</Description>
<AssemblyName>Microsoft.Azure.Functions.Worker.Core</AssemblyName>
Expand All @@ -23,16 +23,18 @@

<ItemGroup>
<PackageReference Include="Azure.Core" Version="1.42.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.1" />
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="8.0.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
<PackageReference Include="System.Text.Encodings.Web" Version="8.0.0" />
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
fabiocav marked this conversation as resolved.
Show resolved Hide resolved
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net9.0'">
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal static class ObjectDisposedThrowHelper
/// <exception cref="ObjectDisposedException">The <paramref name="condition"/> is <see langword="true"/>.</exception>
internal static void ThrowIf(bool condition, object instance)
{
#if NET8_0_OR_GREATER
#if NET7_0_OR_GREATER
ObjectDisposedException.ThrowIf(condition, instance);
#else
if (condition)
Expand Down
4 changes: 2 additions & 2 deletions src/DotNetWorker.Core/Invocation/DefaultMethodInfoLocator.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Reflection;
#if NET8_0_OR_GREATER
#if NET6_0_OR_GREATER
using System.Runtime.Loader;
#endif
using System.Text.RegularExpressions;
Expand All @@ -21,7 +21,7 @@ public MethodInfo GetMethod(string pathToAssembly, string entryPoint)

string typeName = entryPointMatch.Groups["typename"].Value;
string methodName = entryPointMatch.Groups["methodname"].Value;
#if NET8_0_OR_GREATER
#if NET6_0_OR_GREATER
Assembly assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(pathToAssembly);
#else
Assembly assembly = Assembly.LoadFrom(pathToAssembly);
Expand Down
6 changes: 3 additions & 3 deletions src/DotNetWorker.Core/StartupHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void Initialize()
RemoveSelfFromStartupHooks();
string? debuggerWaitEnabled = Environment.GetEnvironmentVariable("FUNCTIONS_ENABLE_DEBUGGER_WAIT");
string? jsonOutputEnabled = Environment.GetEnvironmentVariable("FUNCTIONS_ENABLE_JSON_OUTPUT");
#if NET8_0_OR_GREATER
#if NET6_0_OR_GREATER
int processId = Environment.ProcessId;
#else
int processId = Process.GetCurrentProcess().Id;
Expand All @@ -57,12 +57,12 @@ static bool WaitOnDebugger(int cycle)

if (string.Equals(jsonOutputEnabled, bool.TrueString, StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine($"azfuncjsonlog:{{ \"name\":\"dotnet-worker-startup\", \"workerProcessId\" : { processId } }}");
Console.WriteLine($"azfuncjsonlog:{{ \"name\":\"dotnet-worker-startup\", \"workerProcessId\" : {processId} }}");
}

if (string.Equals(debuggerWaitEnabled, bool.TrueString, StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine($"Azure Functions .NET Worker (PID: { processId }) initialized in debug mode. Waiting for debugger to attach...");
Console.WriteLine($"Azure Functions .NET Worker (PID: {processId}) initialized in debug mode. Waiting for debugger to attach...");

for (int i = 0; WaitOnDebugger(i); i++)
{
Expand Down
2 changes: 1 addition & 1 deletion src/DotNetWorker.Core/WorkerInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal sealed class WorkerInformation

public static WorkerInformation Instance = new();

#if NET8_0_OR_GREATER
#if NET6_0_OR_GREATER
public int ProcessId => Environment.ProcessId;

public string RuntimeIdentifier => RuntimeInformation.RuntimeIdentifier;
Expand Down
11 changes: 2 additions & 9 deletions src/DotNetWorker.Grpc/DotNetWorker.Grpc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>net8.0;net9.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0;netstandard2.0</TargetFrameworks>
<PackageId>Microsoft.Azure.Functions.Worker.Grpc</PackageId>
<Description>This library provides gRPC support for Azure Functions .NET Worker communication with the Azure Functions Host.</Description>
<AssemblyName>Microsoft.Azure.Functions.Worker.Grpc</AssemblyName>
Expand All @@ -22,19 +22,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Azure.Core" Version="1.42.0" />
<PackageReference Include="Google.Protobuf" Version="3.28.0" />
<PackageReference Include="Grpc.Tools" Version="2.66.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Grpc.Tools" Version="2.66.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Abstractions" Version="1.3.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'netstandard2.0'">
<PackageReference Include="Grpc.Net.Client" Version="2.65.0" />
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.65.0" />
</ItemGroup>

Expand Down
8 changes: 4 additions & 4 deletions src/DotNetWorker.Grpc/GrpcServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
using System.Threading.Channels;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Core.FunctionMetadata;
using Microsoft.Azure.Functions.Worker.Diagnostics;
using Microsoft.Azure.Functions.Worker.Grpc;
using Microsoft.Azure.Functions.Worker.Grpc.Messages;
using Microsoft.Azure.Functions.Worker.Handlers;
using Microsoft.Azure.Functions.Worker.Logging;
using Microsoft.Azure.Functions.Worker.Grpc;
using Microsoft.Azure.Functions.Worker.Diagnostics;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Azure.Functions.Worker.Handlers;
using Microsoft.Extensions.Options;

namespace Microsoft.Extensions.DependencyInjection
Expand Down Expand Up @@ -54,7 +54,7 @@ public static IServiceCollection AddGrpc(this IServiceCollection services)
services.TryAddSingleton<IWorker, GrpcWorker>();
services.TryAddSingleton<IInvocationHandler, InvocationHandler>();

#if NET8_0_OR_GREATER
#if NET6_0_OR_GREATER
// If we are running in the native host process, use the native client
// for communication (interop). Otherwise; use the gRPC client.
if (AppContext.GetData("AZURE_FUNCTIONS_NATIVE_HOST") is not null)
Expand Down
4 changes: 2 additions & 2 deletions src/DotNetWorker.Grpc/GrpcWorkerClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using Microsoft.Extensions.Options;
using static Microsoft.Azure.Functions.Worker.Grpc.Messages.FunctionRpc;

#if NET8_0_OR_GREATER
#if NET6_0_OR_GREATER
using Grpc.Net.Client;
#else
using GrpcCore = Grpc.Core;
Expand Down Expand Up @@ -104,7 +104,7 @@ private async Task StartReaderAsync(IAsyncStreamReader<StreamingMessage> respons

private FunctionRpcClient CreateClient()
{
#if NET8_0_OR_GREATER
#if NET6_0_OR_GREATER
GrpcChannel grpcChannel = GrpcChannel.ForAddress(_startupOptions.HostEndpoint!.AbsoluteUri, new GrpcChannelOptions()
{
MaxReceiveMessageSize = _startupOptions.GrpcMaxMessageLength,
Expand Down
10 changes: 5 additions & 5 deletions src/DotNetWorker.Grpc/Http/GrpcHttpRequestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Azure.Functions.Worker.Grpc.Messages;
using Microsoft.Azure.Functions.Worker.Http;

namespace Microsoft.Azure.Functions.Worker
{
internal class GrpcHttpRequestData : HttpRequestData, IDisposable
#if NET8_0_OR_GREATER
#if NET6_0_OR_GREATER
, IAsyncDisposable
#endif
{
Expand Down Expand Up @@ -73,7 +73,7 @@ public override Stream Body
}

var stream = new MemoryStream(memory.Length);
#if NET8_0_OR_GREATER
#if NET6_0_OR_GREATER
stream.Write(memory.Span);
#else
stream.Write(memory.Span.ToArray(), 0, memory.Span.Length);
Expand Down Expand Up @@ -127,7 +127,7 @@ public override HttpResponseData CreateResponse()
return new GrpcHttpResponseData(FunctionContext, System.Net.HttpStatusCode.OK);
}

#if NET8_0_OR_GREATER
#if NET6_0_OR_GREATER
public ValueTask DisposeAsync()
{
return _bodyStream?.DisposeAsync() ?? ValueTask.CompletedTask;
Expand Down Expand Up @@ -159,7 +159,7 @@ private IReadOnlyCollection<IHttpCookie> ToHttpCookies(string cookieString)

List<IHttpCookie> httpCookiesList = new List<IHttpCookie>(separateCookies.Length);

#if NET8_0_OR_GREATER
#if NET6_0_OR_GREATER
var separator = '=';
#else
var separator = new[] { '=' };
Expand Down
9 changes: 9 additions & 0 deletions src/DotNetWorker.Grpc/NativeHostIntegration/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,16 @@ private static IntPtr ImportResolver(string libraryName, System.Reflection.Assem
{
if (libraryName == NativeWorkerDll)
{
#if NET6_0
if (OperatingSystem.IsLinux())
{
return NativeLibraryLinux.GetMainProgramHandle();
}
#elif NET7_0_OR_GREATER
return NativeLibrary.GetMainProgramHandle();
#else
throw new PlatformNotSupportedException("Interop communication with FunctionsNetHost is not supported in the current platform. Consider upgrading your project to .NET 7.0 or later.");
#endif
}

// Return 0 so that built-in resolving code will be executed.
Expand Down
9 changes: 2 additions & 7 deletions src/DotNetWorker/DotNetWorker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>net8.0;net9.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0;netstandard2.0</TargetFrameworks>
<PackageId>Microsoft.Azure.Functions.Worker</PackageId>
<Description>This library enables you to create an Azure Functions .NET Worker, adding support for the isolated, out-of-process execution model.</Description>
<AssemblyName>Microsoft.Azure.Functions.Worker</AssemblyName>
Expand All @@ -16,14 +16,9 @@

<Import Project="..\..\build\Common.props" />

<ItemGroup>
<PackageReference Include="Azure.Core" Version="1.42.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.1" />
</ItemGroup>

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

</Project>