Replacing `#if NET5_0_OR_GREATER` with `#if NET8_0_OR_GREATER`

This commit is contained in:
Shyju Krishnankutty 2024-09-05 14:43:46 -07:00 коммит произвёл Fabio Cavalcante
Родитель 0db2489c84
Коммит 2f3716e891
10 изменённых файлов: 14 добавлений и 23 удалений

Просмотреть файл

@ -75,7 +75,7 @@ namespace Microsoft.Azure.Functions.Worker.Converters
{
if (stream != null)
{
#if NET5_0_OR_GREATER
#if NET8_0_OR_GREATER
await ((IAsyncDisposable)stream).DisposeAsync();
#else

Просмотреть файл

@ -18,7 +18,7 @@ namespace Microsoft.Azure.Functions.Worker.Converters
if (context.TargetType.IsAssignableFrom(typeof(string)))
{
#if NET5_0_OR_GREATER
#if NET8_0_OR_GREATER
var target = Encoding.UTF8.GetString(sourceMemory.Span);
#else
var target = Encoding.UTF8.GetString(sourceMemory.Span.ToArray());

Просмотреть файл

@ -13,7 +13,7 @@ namespace Microsoft.Azure.Functions.Worker
/// <exception cref="ObjectDisposedException">The <paramref name="condition"/> is <see langword="true"/>.</exception>
internal static void ThrowIf(bool condition, object instance)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
ObjectDisposedException.ThrowIf(condition, instance);
#else
if (condition)

Просмотреть файл

@ -1,6 +1,6 @@
using System;
using System.Reflection;
#if NET5_0_OR_GREATER
#if NET8_0_OR_GREATER
using System.Runtime.Loader;
#endif
using System.Text.RegularExpressions;
@ -21,7 +21,7 @@ namespace Microsoft.Azure.Functions.Worker.Invocation
string typeName = entryPointMatch.Groups["typename"].Value;
string methodName = entryPointMatch.Groups["methodname"].Value;
#if NET5_0_OR_GREATER
#if NET8_0_OR_GREATER
Assembly assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(pathToAssembly);
#else
Assembly assembly = Assembly.LoadFrom(pathToAssembly);

Просмотреть файл

@ -32,7 +32,7 @@ internal class StartupHook
RemoveSelfFromStartupHooks();
string? debuggerWaitEnabled = Environment.GetEnvironmentVariable("FUNCTIONS_ENABLE_DEBUGGER_WAIT");
string? jsonOutputEnabled = Environment.GetEnvironmentVariable("FUNCTIONS_ENABLE_JSON_OUTPUT");
#if NET5_0_OR_GREATER
#if NET8_0_OR_GREATER
int processId = Environment.ProcessId;
#else
int processId = Process.GetCurrentProcess().Id;

Просмотреть файл

@ -20,7 +20,7 @@ namespace Microsoft.Azure.Functions.Worker
public static WorkerInformation Instance = new();
#if NET5_0_OR_GREATER
#if NET8_0_OR_GREATER
public int ProcessId => Environment.ProcessId;
public string RuntimeIdentifier => RuntimeInformation.RuntimeIdentifier;

Просмотреть файл

@ -51,7 +51,7 @@ namespace Microsoft.Extensions.DependencyInjection
services.AddSingleton<IWorker, GrpcWorker>();
services.TryAddSingleton<IInvocationHandler, InvocationHandler>();
#if NET5_0_OR_GREATER
#if NET8_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)

Просмотреть файл

@ -10,7 +10,7 @@ using Microsoft.Azure.Functions.Worker.Grpc.Messages;
using Microsoft.Extensions.Options;
using static Microsoft.Azure.Functions.Worker.Grpc.Messages.FunctionRpc;
#if NET5_0_OR_GREATER
#if NET8_0_OR_GREATER
using Grpc.Net.Client;
#else
using GrpcCore = Grpc.Core;
@ -104,7 +104,7 @@ namespace Microsoft.Azure.Functions.Worker.Grpc
private FunctionRpcClient CreateClient()
{
#if NET5_0_OR_GREATER
#if NET8_0_OR_GREATER
GrpcChannel grpcChannel = GrpcChannel.ForAddress(_startupOptions.HostEndpoint!.AbsoluteUri, new GrpcChannelOptions()
{
MaxReceiveMessageSize = _startupOptions.GrpcMaxMessageLength,

Просмотреть файл

@ -13,7 +13,7 @@ using Microsoft.Azure.Functions.Worker.Grpc.Messages;
namespace Microsoft.Azure.Functions.Worker
{
internal class GrpcHttpRequestData : HttpRequestData, IDisposable
#if NET5_0_OR_GREATER
#if NET8_0_OR_GREATER
, IAsyncDisposable
#endif
{
@ -73,7 +73,7 @@ namespace Microsoft.Azure.Functions.Worker
}
var stream = new MemoryStream(memory.Length);
#if NET5_0_OR_GREATER
#if NET8_0_OR_GREATER
stream.Write(memory.Span);
#else
stream.Write(memory.Span.ToArray(), 0, memory.Span.Length);
@ -127,7 +127,7 @@ namespace Microsoft.Azure.Functions.Worker
return new GrpcHttpResponseData(FunctionContext, System.Net.HttpStatusCode.OK);
}
#if NET5_0_OR_GREATER
#if NET8_0_OR_GREATER
public ValueTask DisposeAsync()
{
return _bodyStream?.DisposeAsync() ?? ValueTask.CompletedTask;
@ -159,7 +159,7 @@ namespace Microsoft.Azure.Functions.Worker
List<IHttpCookie> httpCookiesList = new List<IHttpCookie>(separateCookies.Length);
#if NET5_0_OR_GREATER
#if NET8_0_OR_GREATER
var separator = '=';
#else
var separator = new[] { '=' };

Просмотреть файл

@ -49,16 +49,7 @@ namespace Microsoft.Azure.Functions.Worker.Grpc.NativeHostIntegration
{
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.