Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Add C# code snippets to retries documentation

Summary

Added C# code examples to the retries with backoff documentation page showing how to configure retry limits in the C# SDK. The examples demonstrate:

  1. Overriding the default retry limit at the client level using ClientOptions
  2. Overriding the retry limit on a per-request basis using RequestOptions

The C# examples follow the same pattern as the existing TypeScript, Python, Java, and Go examples.

Review & Testing Checklist for Human

  • Verify the C# syntax is correct and matches actual generated Fern C# SDKs (I researched this by examining generated SDK code in the fern/seed directory, but couldn't test with a live SDK)
  • Confirm the MaxRetries property name is correct (not maxRetries or max_retries)
  • Check that line highlighting ({3} and {2}) points to the correct lines in the rendered documentation
  • Preview the documentation page to ensure code blocks render properly and syntax highlighting works

Test Plan

  1. Run fern docs dev and navigate to /learn/sdks/deep-dives/retries-with-backoff
  2. Verify the C# code blocks appear in the correct sections alongside other language examples
  3. Check that the syntax highlighting and line highlighting display correctly

Notes

  • Based on research of generated SDK code at /home/ubuntu/repos/fern/seed/csharp-sdk/content-type/src/SeedContentTypes/Core/Public/ClientOptions.cs and RequestOptions.cs
  • The MaxRetries property has a default value of 2 in ClientOptions and is nullable (int?) in RequestOptions
  • Documentation dev server validated successfully without errors

Link to Devin run: https://app.devin.ai/sessions/01db27cf4ef24988b620fff821b1f656
Requested by: Niels Swimberghe ([email protected], @Swimburger)

@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions
Copy link
Contributor

@Swimburger
Copy link
Member

This looks good, thank you. Can you also add snippets for Ruby and PHP?

@Swimburger
Copy link
Member

Also include it for Swift. Make sure the max retries client options and request options actually exist in the generated SDKs first.

- Added Swift examples for client-level and request-level retry configuration
- Added PHP examples for client-level and request-level retry configuration
- Verified retry support exists in generated SDKs before adding examples
- Ruby retry support not implemented (parameter exists but not used in RawClient)

Co-Authored-By: Niels Swimberghe <[email protected]>
@devin-ai-integration
Copy link
Contributor Author

I've verified retry support in the generated SDKs and added examples for Swift and PHP. Here's what I found:

Verification Results

✅ Swift - Retry support confirmed

  • Client-level: ClientConfig has maxRetries: Int property (default: 2)
    • Source: /seed/swift-sdk/content-type/Sources/Public/ClientConfig.swift:54
  • Request-level: RequestOptions has maxRetries: Int? property
    • Source: /seed/swift-sdk/content-type/Sources/Public/RequestOptions.swift:17
  • Usage: Methods accept requestOptions: RequestOptions? parameter
    • Source: /seed/swift-sdk/content-type/Sources/Resources/Service/ServiceClient.swift:10

✅ PHP - Retry support confirmed

  • Client-level: Client constructor accepts maxRetries in options array
    • Source: /seed/php-sdk/content-type/src/SeedClient.php:20,36
  • Request-level: Service methods accept maxRetries in options array
    • Source: /seed/php-sdk/content-type/src/Service/ServiceClient.php:59,115,169,224,277
  • Implementation: RetryMiddleware implements exponential backoff with default maxRetries: 2
    • Source: /seed/php-sdk/content-type/src/Core/Client/RetryMiddleware.php:15

✅ C# - Retry support confirmed (from earlier verification)

  • Client-level: ClientOptions has MaxRetries property (default: 2)
  • Request-level: RequestOptions has MaxRetries property (nullable int)

❌ Ruby - Retry support NOT implemented

  • Issue: While RawClient constructor accepts max_retries: parameter and stores it in @max_retries, the retry functionality is not actually implemented:
    • The send method does not use @max_retries for any retry logic
      • Source: /seed/ruby-sdk-v2/content-type/lib/seed/internal/http/raw_client.rb:25-47
    • The connect method explicitly sets http.max_retries = 0, disabling Net::HTTP's built-in retry mechanism
      • Source: /seed/ruby-sdk-v2/content-type/lib/seed/internal/http/raw_client.rb:99
    • Request-level request_options only supports :base_url, not :max_retries
      • Source: /seed/ruby-sdk-v2/content-type/lib/seed/service/client.rb:14

Conclusion: I have not added Ruby examples since the retry functionality is not implemented in the generated SDKs. If there's a different Ruby generator version that does support retries, please let me know and I can add examples for it.

Changes Made

  • ✅ Added Swift client-level and request-level retry examples
  • ✅ Added PHP client-level and request-level retry examples
  • ✅ Kept C# examples (already verified)
  • ❌ Did not add Ruby examples (retry not implemented)

The documentation has been tested locally with fern docs dev and builds successfully.

@github-actions
Copy link
Contributor

@Swimburger
Copy link
Member

The highlighted lines sometimes highlight the wrong line in the code samples you added.

- Changed C# client-level highlight from {3} to {4}
- Changed Swift client-level highlight from {4} to {5}
- Changed PHP client-level highlight from {3} to {4}
- All highlights now correctly point to the maxRetries configuration line

Co-Authored-By: Niels Swimberghe <[email protected]>
@github-actions
Copy link
Contributor

Copy link
Member

@kafkas kafkas left a comment

Choose a reason for hiding this comment

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

Swift looks good

Removed blank lines after import statements in C# and PHP client-level
examples to fix line highlighting. The blank lines were causing the
renderer to highlight the wrong line (one line too early).

- C# client-level: Changed from {4} to {3} and removed blank line
- PHP client-level: Changed from {4} to {3} and removed blank line
- Per-request examples were already correct
- Swift examples were already correct

Verified locally with fern docs dev that highlighting now correctly
points to the MaxRetries/maxRetries configuration lines.

Co-Authored-By: Niels Swimberghe <[email protected]>
@github-actions
Copy link
Contributor

@devin-ai-integration
Copy link
Contributor Author

Fixed the line highlighting issue in C# and PHP client-level examples. The problem was that blank lines after the import statements were causing the renderer to highlight one line too early.

Changes made:

  • Removed blank line after using Imdb; in C# client-level example
  • Removed blank line after use Imdb\ImdbClient; in PHP client-level example
  • Changed line highlighting from {4} to {3} for both examples

Verification:

  • Tested locally with fern docs dev and confirmed highlighting now correctly points to the MaxRetries/maxRetries configuration lines
  • Swift examples were already correct (no blank line after import)
  • Per-request examples for all languages were already correct

The highlighting now works correctly for all code snippets added.

@JustSteveKing
Copy link

PHP is looking good.

The PR preview renderer adds blank lines after import/use statements,
shifting line numbers. Updated highlighting from {3} to {4} to correctly
highlight the maxRetries/MaxRetries configuration line.

Co-Authored-By: Niels Swimberghe <[email protected]>
@github-actions
Copy link
Contributor

@Swimburger Swimburger merged commit cf1173b into main Oct 30, 2025
2 checks passed
@Swimburger Swimburger deleted the devin/1761771571-add-csharp-retries-snippets branch October 30, 2025 16:26
@github-actions
Copy link
Contributor

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.

4 participants