From d8b5fe998a8c92819b8ee41d2569d2525413e9c5 Mon Sep 17 00:00:00 2001 From: Brett Samblanet Date: Tue, 12 Nov 2024 11:57:08 -0800 Subject: [PATCH] Add .net9 transitive dependencies (#2852) * Add .net9 transitive dependencies * more cleanup * adding net6 as target; moving to net9.0 * fixes * updating #ifs * updating sdk * bumping azure.core * removing previews * bumping global.json --------- Co-authored-by: Jacob Viau --- global.json | 2 +- sdk/Sdk/Sdk.csproj | 3 +-- .../DotNetWorker.ApplicationInsights.csproj | 3 +-- .../Converters/JsonPocoConverter.cs | 4 +-- .../Converters/MemoryConverter.cs | 2 +- .../DotNetWorker.Core.csproj | 27 ++++++++++--------- .../ThrowHelpers/ObjectDisposedThrowHelper.cs | 2 +- .../Invocation/DefaultMethodInfoLocator.cs | 4 +-- src/DotNetWorker.Core/StartupHook.cs | 6 ++--- src/DotNetWorker.Core/WorkerInformation.cs | 2 +- .../DotNetWorker.Grpc.csproj | 14 +++------- .../GrpcServiceCollectionExtensions.cs | 8 +++--- .../GrpcWorkerClientFactory.cs | 4 +-- .../Http/GrpcHttpRequestData.cs | 10 +++---- .../NativeHostIntegration/NativeMethods.cs | 9 +++++++ .../DotNetWorker.OpenTelemetry.csproj | 2 +- src/DotNetWorker/DotNetWorker.csproj | 10 ++----- 17 files changed, 53 insertions(+), 59 deletions(-) diff --git a/global.json b/global.json index e8630fed2..ec9ccb01a 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "9.0.100-preview.6.24328.19", + "version": "9.0.100", "allowPrerelease": true, "rollForward": "latestPatch" }, diff --git a/sdk/Sdk/Sdk.csproj b/sdk/Sdk/Sdk.csproj index 29703f966..4563be3e4 100644 --- a/sdk/Sdk/Sdk.csproj +++ b/sdk/Sdk/Sdk.csproj @@ -1,8 +1,7 @@  - 2 - -preview2 + 2 netstandard2.0;net472 Microsoft.Azure.Functions.Worker.Sdk This package provides development time support for the Azure Functions .NET Worker. diff --git a/src/DotNetWorker.ApplicationInsights/DotNetWorker.ApplicationInsights.csproj b/src/DotNetWorker.ApplicationInsights/DotNetWorker.ApplicationInsights.csproj index d8f263eae..1ab568c0e 100644 --- a/src/DotNetWorker.ApplicationInsights/DotNetWorker.ApplicationInsights.csproj +++ b/src/DotNetWorker.ApplicationInsights/DotNetWorker.ApplicationInsights.csproj @@ -8,8 +8,7 @@ 2 0 0 - README.md - -preview5 + README.md $(BeforePack);GetReleaseNotes diff --git a/src/DotNetWorker.Core/Converters/JsonPocoConverter.cs b/src/DotNetWorker.Core/Converters/JsonPocoConverter.cs index 800c0a3d4..65710d929 100644 --- a/src/DotNetWorker.Core/Converters/JsonPocoConverter.cs +++ b/src/DotNetWorker.Core/Converters/JsonPocoConverter.cs @@ -73,9 +73,9 @@ private async Task GetConversionResultFromDeserialization(byte } finally { - if (stream != null) + if (stream != null) { -#if NET8_0_OR_GREATER +#if NET6_0_OR_GREATER await ((IAsyncDisposable)stream).DisposeAsync(); #else diff --git a/src/DotNetWorker.Core/Converters/MemoryConverter.cs b/src/DotNetWorker.Core/Converters/MemoryConverter.cs index 28fdbedce..6915bb322 100644 --- a/src/DotNetWorker.Core/Converters/MemoryConverter.cs +++ b/src/DotNetWorker.Core/Converters/MemoryConverter.cs @@ -18,7 +18,7 @@ public ValueTask 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()); diff --git a/src/DotNetWorker.Core/DotNetWorker.Core.csproj b/src/DotNetWorker.Core/DotNetWorker.Core.csproj index a88d02c49..1d5562418 100644 --- a/src/DotNetWorker.Core/DotNetWorker.Core.csproj +++ b/src/DotNetWorker.Core/DotNetWorker.Core.csproj @@ -2,7 +2,7 @@ Library - net8.0;net9.0;netstandard2.0 + net6.0;net8.0;net9.0;netstandard2.0 Microsoft.Azure.Functions.Worker.Core This library provides the core functionality to build an Azure Functions .NET Worker, adding support for the isolated, out-of-process execution model. Microsoft.Azure.Functions.Worker.Core @@ -10,8 +10,7 @@ true 2 0 - 0 - -preview5 + 0 @@ -22,17 +21,19 @@ - - - - - + - + - - - - + + + + + + + + + + diff --git a/src/DotNetWorker.Core/Helpers/ThrowHelpers/ObjectDisposedThrowHelper.cs b/src/DotNetWorker.Core/Helpers/ThrowHelpers/ObjectDisposedThrowHelper.cs index ec7cb6fe7..9516b0d10 100644 --- a/src/DotNetWorker.Core/Helpers/ThrowHelpers/ObjectDisposedThrowHelper.cs +++ b/src/DotNetWorker.Core/Helpers/ThrowHelpers/ObjectDisposedThrowHelper.cs @@ -13,7 +13,7 @@ internal static class ObjectDisposedThrowHelper /// The is . 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) diff --git a/src/DotNetWorker.Core/Invocation/DefaultMethodInfoLocator.cs b/src/DotNetWorker.Core/Invocation/DefaultMethodInfoLocator.cs index 0d149f1f6..5ab64e6f2 100644 --- a/src/DotNetWorker.Core/Invocation/DefaultMethodInfoLocator.cs +++ b/src/DotNetWorker.Core/Invocation/DefaultMethodInfoLocator.cs @@ -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; @@ -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); diff --git a/src/DotNetWorker.Core/StartupHook.cs b/src/DotNetWorker.Core/StartupHook.cs index 575b8513f..baea73d30 100644 --- a/src/DotNetWorker.Core/StartupHook.cs +++ b/src/DotNetWorker.Core/StartupHook.cs @@ -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; @@ -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++) { diff --git a/src/DotNetWorker.Core/WorkerInformation.cs b/src/DotNetWorker.Core/WorkerInformation.cs index 35e7482b0..fc8b79285 100644 --- a/src/DotNetWorker.Core/WorkerInformation.cs +++ b/src/DotNetWorker.Core/WorkerInformation.cs @@ -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; diff --git a/src/DotNetWorker.Grpc/DotNetWorker.Grpc.csproj b/src/DotNetWorker.Grpc/DotNetWorker.Grpc.csproj index 87a0038fe..69bc14427 100644 --- a/src/DotNetWorker.Grpc/DotNetWorker.Grpc.csproj +++ b/src/DotNetWorker.Grpc/DotNetWorker.Grpc.csproj @@ -2,7 +2,7 @@ Library - net8.0;net9.0;netstandard2.0 + net6.0;net7.0;net8.0;net9.0;netstandard2.0 Microsoft.Azure.Functions.Worker.Grpc This library provides gRPC support for Azure Functions .NET Worker communication with the Azure Functions Host. Microsoft.Azure.Functions.Worker.Grpc @@ -10,8 +10,7 @@ true 2 0 - 0 - -preview5 + 0 true @@ -22,19 +21,12 @@ - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + - - - diff --git a/src/DotNetWorker.Grpc/GrpcServiceCollectionExtensions.cs b/src/DotNetWorker.Grpc/GrpcServiceCollectionExtensions.cs index 7c8c0ff54..3dc7ac839 100644 --- a/src/DotNetWorker.Grpc/GrpcServiceCollectionExtensions.cs +++ b/src/DotNetWorker.Grpc/GrpcServiceCollectionExtensions.cs @@ -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 @@ -54,7 +54,7 @@ public static IServiceCollection AddGrpc(this IServiceCollection services) services.TryAddSingleton(); services.TryAddSingleton(); -#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) diff --git a/src/DotNetWorker.Grpc/GrpcWorkerClientFactory.cs b/src/DotNetWorker.Grpc/GrpcWorkerClientFactory.cs index aecb5f093..fa1251371 100644 --- a/src/DotNetWorker.Grpc/GrpcWorkerClientFactory.cs +++ b/src/DotNetWorker.Grpc/GrpcWorkerClientFactory.cs @@ -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; @@ -104,7 +104,7 @@ private async Task StartReaderAsync(IAsyncStreamReader 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, diff --git a/src/DotNetWorker.Grpc/Http/GrpcHttpRequestData.cs b/src/DotNetWorker.Grpc/Http/GrpcHttpRequestData.cs index d4a7118a0..76a0d5c82 100644 --- a/src/DotNetWorker.Grpc/Http/GrpcHttpRequestData.cs +++ b/src/DotNetWorker.Grpc/Http/GrpcHttpRequestData.cs @@ -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 { @@ -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); @@ -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; @@ -159,7 +159,7 @@ private IReadOnlyCollection ToHttpCookies(string cookieString) List httpCookiesList = new List(separateCookies.Length); -#if NET8_0_OR_GREATER +#if NET6_0_OR_GREATER var separator = '='; #else var separator = new[] { '=' }; diff --git a/src/DotNetWorker.Grpc/NativeHostIntegration/NativeMethods.cs b/src/DotNetWorker.Grpc/NativeHostIntegration/NativeMethods.cs index 7a57591d4..ebaeea44c 100644 --- a/src/DotNetWorker.Grpc/NativeHostIntegration/NativeMethods.cs +++ b/src/DotNetWorker.Grpc/NativeHostIntegration/NativeMethods.cs @@ -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. diff --git a/src/DotNetWorker.OpenTelemetry/DotNetWorker.OpenTelemetry.csproj b/src/DotNetWorker.OpenTelemetry/DotNetWorker.OpenTelemetry.csproj index e2cc658ec..e9d0947e4 100644 --- a/src/DotNetWorker.OpenTelemetry/DotNetWorker.OpenTelemetry.csproj +++ b/src/DotNetWorker.OpenTelemetry/DotNetWorker.OpenTelemetry.csproj @@ -8,7 +8,7 @@ 1 1 0 - -preview5 + -preview6 README.md $(BeforePack);GetReleaseNotes diff --git a/src/DotNetWorker/DotNetWorker.csproj b/src/DotNetWorker/DotNetWorker.csproj index d5cffeeef..b68c14392 100644 --- a/src/DotNetWorker/DotNetWorker.csproj +++ b/src/DotNetWorker/DotNetWorker.csproj @@ -2,7 +2,7 @@ Library - net8.0;net9.0;netstandard2.0 + net6.0;net7.0;net8.0;net9.0;netstandard2.0 Microsoft.Azure.Functions.Worker This library enables you to create an Azure Functions .NET Worker, adding support for the isolated, out-of-process execution model. Microsoft.Azure.Functions.Worker @@ -11,19 +11,13 @@ 2 0 0 - -preview5 - - - - - - +