Skip to content

Commit

Permalink
net8.0 target follow up (#47214)
Browse files Browse the repository at this point in the history
m-redding authored Nov 27, 2024
1 parent 173217a commit 664b5fd
Showing 3 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -86,8 +86,13 @@ private static IReadOnlyDictionary<string, Type> GetBindingDataContract(Paramete
public async Task<ITriggerData> BindAsync(object value, ValueBindingContext context)
{
var request = (HttpRequestMessage)value;
#if NET8_0_OR_GREATER
HttpRequestOptionsKey<WebJobsAuthenticationEventResponseHandler> httpRequestOptionsKey = new(WebJobsAuthenticationEventResponseHandler.EventResponseProperty);
request.Options.TryGetValue(httpRequestOptionsKey, out WebJobsAuthenticationEventResponseHandler eventResponseHandler);
#else
WebJobsAuthenticationEventResponseHandler eventResponseHandler =
(WebJobsAuthenticationEventResponseHandler)request.Properties[WebJobsAuthenticationEventResponseHandler.EventResponseProperty];
#endif
try
{
if (request == null)
Original file line number Diff line number Diff line change
@@ -109,7 +109,12 @@ public async Task<HttpResponseMessage> ConvertAsync(HttpRequestMessage input, Ca
//We create an event response handler and attach it to the income HTTP message, then on the trigger we set the function response
//in the event response handler and after the executor calls the functions we have reference to the function response.
WebJobsAuthenticationEventResponseHandler eventsResponseHandler = new WebJobsAuthenticationEventResponseHandler();
#if NET8_0_OR_GREATER
HttpRequestOptionsKey<WebJobsAuthenticationEventResponseHandler> httpRequestOptionsKey = new(WebJobsAuthenticationEventResponseHandler.EventResponseProperty);
input.Options.Set(httpRequestOptionsKey, eventsResponseHandler);
#else
input.Properties.Add(WebJobsAuthenticationEventResponseHandler.EventResponseProperty, eventsResponseHandler);
#endif

TriggeredFunctionData triggerData = new TriggeredFunctionData()
{
Original file line number Diff line number Diff line change
@@ -115,12 +115,16 @@ public async Task<FunctionResult> ExecuteAsync(QueueMessage value, CancellationT
// Include the queue details here.
IDictionary<string, string> details = PopulateTriggerDetails(value);

#pragma warning disable CS8073 // The result of the expression is always true in net8.0, but not this is not true in netstandard2.0
if (blobProperties.CreatedOn != null)
#pragma warning restore CS8073
{
details[BlobCreatedKey] = blobProperties.CreatedOn.ToString(Constants.DateTimeFormatString, CultureInfo.InvariantCulture);
}

#pragma warning disable CS8073 // The result of the expression is always true in net8.0, but not this is not true in netstandard2.0
if (blobProperties.LastModified != null)
#pragma warning restore CS8073
{
details[BlobLastModifiedKey] = blobProperties.LastModified.ToString(Constants.DateTimeFormatString, CultureInfo.InvariantCulture);
}

0 comments on commit 664b5fd

Please sign in to comment.