Skip to content

Conversation

@cjaliaga
Copy link
Member

@cjaliaga cjaliaga commented Oct 31, 2025

Issue describing the changes in this PR

This PR implements IOptionsFormatter for ScriptJobHostOptions:

{
  "FileWatchingEnabled": true,
  "FileLoggingMode": "DebugOnly",
  "FunctionTimeout": "01:00:00",
  "TelemetryMode": "ApplicationInsights"
}

resolves #11460

Pull request checklist

IMPORTANT: Currently, changes must be backported to the in-proc branch to be included in Core Tools and non-Flex deployments.

  • Backporting to the in-proc branch is not required
    • Otherwise: Link to backporting PR
  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • My changes do not require diagnostic events changes
    • Otherwise: I have added/updated all related diagnostic events and their documentation (Documentation issue linked to PR)
  • I have added all required tests (Unit tests, E2E tests)

@cjaliaga cjaliaga requested a review from a team as a code owner October 31, 2025 21:54
Copilot AI review requested due to automatic review settings October 31, 2025 21:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds serialization support to ScriptJobHostOptions by implementing the IOptionsFormatter interface, enabling the class to format its options as JSON. This allows the options to be logged or displayed consistently with other option types in the codebase.

  • Implements IOptionsFormatter interface with a custom JSON converter
  • Adds comprehensive test coverage for the Format() method
  • Serializes key properties: FileWatchingEnabled, FileLoggingMode, FunctionTimeout, and TelemetryMode

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/WebJobs.Script/Config/ScriptJobHostOptions.cs Implements IOptionsFormatter interface with a custom JsonConverter to selectively serialize specific properties
test/WebJobs.Script.Tests/Configuration/ScriptJobHostOptionsTests.cs Adds unit tests verifying JSON serialization behavior including null handling and formatting

support JSON serialization with a custom converter. Added a
Format method for serializing options to JSON. Introduced unit
tests to validate serialization logic.
@fabiocav fabiocav merged commit 7a8b864 into dev Nov 12, 2025
9 checks passed
@fabiocav fabiocav deleted the cjaliaga/11460 branch November 12, 2025 21:04
throw new NotImplementedException();
}

public override void Write(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need custom JsonConverter?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've considered adding the JsonSourceGenerationOptions attribute to use source generation to create a SerializationContext as we do in other Options classes. However, since we didn't want to log all the properties but a few, almost all the properties would have ended with a JsonIgnore attribute and didn't like that approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Log ScriptJobHostOptions in startup logs

6 participants