Skip to content

Commit

Permalink
Add .net9 transitive dependencies (#2852)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
brettsam and jviau authored Nov 12, 2024
1 parent 280e4fd commit d8b5fe9
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 59 deletions.
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "9.0.100-preview.6.24328.19",
"version": "9.0.100",
"allowPrerelease": true,
"rollForward": "latestPatch"
},
Expand Down
3 changes: 1 addition & 2 deletions sdk/Sdk/Sdk.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<MajorProductVersion>2</MajorProductVersion>
<VersionSuffix>-preview2</VersionSuffix>
<MajorProductVersion>2</MajorProductVersion>
<TargetFrameworks>netstandard2.0;net472</TargetFrameworks>
<PackageId>Microsoft.Azure.Functions.Worker.Sdk</PackageId>
<Description>This package provides development time support for the Azure Functions .NET Worker.</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
<MajorProductVersion>2</MajorProductVersion>
<MinorProductVersion>0</MinorProductVersion>
<PatchProductVersion>0</PatchProductVersion>
<PackageReadmeFile>README.md</PackageReadmeFile>
<VersionSuffix>-preview5</VersionSuffix>
<PackageReadmeFile>README.md</PackageReadmeFile>
<BeforePack>$(BeforePack);GetReleaseNotes</BeforePack>
</PropertyGroup>

Expand Down
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
27 changes: 14 additions & 13 deletions src/DotNetWorker.Core/DotNetWorker.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

<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>
<RootNamespace>Microsoft.Azure.Functions.Worker.Core</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<MajorProductVersion>2</MajorProductVersion>
<MinorProductVersion>0</MinorProductVersion>
<PatchProductVersion>0</PatchProductVersion>
<VersionSuffix>-preview5</VersionSuffix>
<PatchProductVersion>0</PatchProductVersion>
</PropertyGroup>

<Import Project="..\..\build\Common.props" />
Expand All @@ -22,17 +21,19 @@
</ItemGroup>

<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" />
<PackageReference Include="Azure.Core" Version="1.44.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" />
</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
14 changes: 3 additions & 11 deletions src/DotNetWorker.Grpc/DotNetWorker.Grpc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

<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>
<RootNamespace>Microsoft.Azure.Functions.Worker.Grpc</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<MajorProductVersion>2</MajorProductVersion>
<MinorProductVersion>0</MinorProductVersion>
<PatchProductVersion>0</PatchProductVersion>
<VersionSuffix>-preview5</VersionSuffix>
<PatchProductVersion>0</PatchProductVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

Expand All @@ -22,19 +21,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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<MajorProductVersion>1</MajorProductVersion>
<MinorProductVersion>1</MinorProductVersion>
<PatchProductVersion>0</PatchProductVersion>
<VersionSuffix>-preview5</VersionSuffix>
<VersionSuffix>-preview6</VersionSuffix>
<PackageReadmeFile>README.md</PackageReadmeFile>
<BeforePack>$(BeforePack);GetReleaseNotes</BeforePack>
</PropertyGroup>
Expand Down
10 changes: 2 additions & 8 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 @@ -11,19 +11,13 @@
<MajorProductVersion>2</MajorProductVersion>
<MinorProductVersion>0</MinorProductVersion>
<PatchProductVersion>0</PatchProductVersion>
<VersionSuffix>-preview5</VersionSuffix>
</PropertyGroup>

<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>

0 comments on commit d8b5fe9

Please sign in to comment.