Skip to content

Commit

Permalink
Moving WebJobs.Script to .NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiocav committed Jan 15, 2025
1 parent 969f761 commit 573a9d7
Show file tree
Hide file tree
Showing 15 changed files with 14 additions and 52 deletions.
1 change: 1 addition & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
- [Added net9 prelaunch app.](https://github.com/Azure/azure-functions-dotnet-worker/pull/2898)
- Update the `DefaultHttpProxyService` to better handle client disconnect scenarios (#10688)
- Replaced `InvalidOperationException` with `HttpForwardingException` when there is a ForwarderError
- Updated `WebJobs.Script` to target .NET 8 (instead of .NET Standard 2.1)
2 changes: 1 addition & 1 deletion src/WebJobs.Script/Binding/Http/RawScriptResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public async Task ExecuteResultAsync(ActionContext context)
}
else
{
response.Headers.Add(header.Key, header.Value.ToString() ?? string.Empty);
response.Headers.Append(header.Key, header.Value.ToString() ?? string.Empty);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/WebJobs.Script/Binding/Http/ScriptObjectResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal void AddResponseHeaders(HttpContext context)
}
else
{
response.Headers.Add(header.Key, header.Value.ToString() ?? string.Empty);
response.Headers.Append(header.Key, header.Value.ToString() ?? string.Empty);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Microsoft.Azure.WebJobs.Script.Description
{
[Serializable]
public sealed class CompilationServiceException : Exception
{
public CompilationServiceException()
Expand All @@ -25,9 +24,5 @@ public CompilationServiceException(string message) : base(message)
public CompilationServiceException(string message, Exception innerException) : base(message, innerException)
{
}

private CompilationServiceException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
2 changes: 2 additions & 0 deletions src/WebJobs.Script/Extensions/AssemblyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public static string GetCodeBase(this Assembly assembly)
return codeBase;
}

#pragma warning disable SYSLIB0012 // Type or member is obsolete
return assembly.CodeBase;
#pragma warning restore SYSLIB0012 // Type or member is obsolete
}
}
}
5 changes: 0 additions & 5 deletions src/WebJobs.Script/ExternalStartupException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@ namespace Microsoft.Azure.WebJobs.Script
/// An exception that indicates an issue calling into an external Startup class. This will
/// prevent the host from starting.
/// </summary>
[Serializable]
public class ExternalStartupException : Exception
{
public ExternalStartupException() { }

public ExternalStartupException(string message) : base(message) { }

public ExternalStartupException(string message, Exception inner) : base(message, inner) { }

protected ExternalStartupException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
}
}
5 changes: 0 additions & 5 deletions src/WebJobs.Script/FunctionConfigurationException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@ namespace Microsoft.Azure.WebJobs.Script
/// An exception that indicates an issue with a function. These exceptions will be caught and
/// logged, but not cause a host to restart.
/// </summary>
[Serializable]
public class FunctionConfigurationException : Exception
{
public FunctionConfigurationException() { }

public FunctionConfigurationException(string message) : base(message) { }

public FunctionConfigurationException(string message, Exception inner) : base(message, inner) { }

protected FunctionConfigurationException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
}
}
2 changes: 1 addition & 1 deletion src/WebJobs.Script/Host/ProxyFunctionProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private ImmutableArray<FunctionMetadata> LoadFunctionMetadata()
var functionErrors = new Dictionary<string, ICollection<string>>();
Collection<ProxyFunctionMetadata> proxies = ReadProxyMetadata(_scriptOptions.Value.RootScriptPath, _logger, functionErrors);

ImmutableArray<FunctionMetadata> metadata;
ImmutableArray<FunctionMetadata> metadata = ImmutableArray<FunctionMetadata>.Empty;
if (proxies != null && proxies.Any())
{
metadata = proxies.ToImmutableArray<FunctionMetadata>();
Expand Down
5 changes: 0 additions & 5 deletions src/WebJobs.Script/HostConfigurationException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@ namespace Microsoft.Azure.WebJobs.Script
/// An exception that indicates an issue configuring a ScriptHost. This will
/// prevent the host from starting.
/// </summary>
[Serializable]
public class HostConfigurationException : Exception
{
public HostConfigurationException() { }

public HostConfigurationException(string message) : base(message) { }

public HostConfigurationException(string message, Exception inner) : base(message, inner) { }

protected HostConfigurationException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
}
}
19 changes: 0 additions & 19 deletions src/WebJobs.Script/HostDisposedException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace Microsoft.Azure.WebJobs.Script
/// <summary>
/// An exception that indicates that a service was used on a disposed host.
/// </summary>
[Serializable]
public class HostDisposedException : ObjectDisposedException
{
// For this exception, we want a full stack trace to pinpoint the method
Expand All @@ -24,31 +23,13 @@ public HostDisposedException(string disposedObjectName, Exception inner)
_stackTraceString = GetStackTraceString();
}

protected HostDisposedException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
if (info == null)
{
throw new ArgumentNullException(nameof(info));
}

_stackTraceString = info.GetString("FullStackTraceString");
}

public override string StackTrace => _stackTraceString;

public string GetStackTraceString()
{
return new StackTrace(true).ToString();
}

public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);

info.AddValue("FullStackTraceString", _stackTraceString);
}

private static string GetDefaultMessage(string disposedObjectName)
{
string message = $"The host is disposed and cannot be used. Disposed object: '{disposedObjectName}'";
Expand Down
5 changes: 0 additions & 5 deletions src/WebJobs.Script/HostInitializationException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,12 @@ namespace Microsoft.Azure.WebJobs.Script
/// <summary>
/// An exception that indicates an issue initializing a ScriptHost.
/// </summary>
[Serializable]
public class HostInitializationException : Exception
{
public HostInitializationException() { }

public HostInitializationException(string message) : base(message) { }

public HostInitializationException(string message, Exception inner) : base(message, inner) { }

protected HostInitializationException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
}
}
4 changes: 0 additions & 4 deletions src/WebJobs.Script/InvalidHostServicesException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@ namespace Microsoft.Azure.WebJobs.Script
/// An exception that indicates an issue with the registerd services for a ScriptHost. This will
/// prevent the host from starting.
/// </summary>
[Serializable]
public class InvalidHostServicesException : Exception
{
public InvalidHostServicesException() { }

public InvalidHostServicesException(string message) : base(message) { }

public InvalidHostServicesException(string message, Exception inner) : base(message, inner) { }

protected InvalidHostServicesException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
}
2 changes: 1 addition & 1 deletion src/WebJobs.Script/WebJobs.Script.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<PackageId>Microsoft.Azure.WebJobs.Script</PackageId>
<AssemblyName>Microsoft.Azure.WebJobs.Script</AssemblyName>
<RootNamespace>Microsoft.Azure.WebJobs.Script</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ public IList<RpcWorkerConfig> GetConfigs()

internal static string GetDefaultWorkersDirectory(Func<string, bool> directoryExists)
{
#pragma warning disable SYSLIB0012 // Type or member is obsolete
string assemblyLocalPath = Path.GetDirectoryName(new Uri(typeof(RpcWorkerConfigFactory).Assembly.CodeBase).LocalPath);
#pragma warning restore SYSLIB0012 // Type or member is obsolete
string workersDirPath = Path.Combine(assemblyLocalPath, RpcWorkerConstants.DefaultWorkersDirectoryName);
if (!directoryExists(workersDirPath))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public override bool TryCreate(string mapName, long size, out MemoryMappedFile m

public override bool TryOpen(string mapName, out MemoryMappedFile mmf)
{
if (!OperatingSystem.IsWindows())
{
throw new PlatformNotSupportedException($"{nameof(TryOpen)} is not supported on the current platform.");
}

mmf = null;

try
Expand Down

0 comments on commit 573a9d7

Please sign in to comment.