Skip to content

feat(ofrep): AOT compatibility#651

Open
aldy505 wants to merge 7 commits into
open-feature:mainfrom
aldy505:feat/aot-compatibility
Open

feat(ofrep): AOT compatibility#651
aldy505 wants to merge 7 commits into
open-feature:mainfrom
aldy505:feat/aot-compatibility

Conversation

@aldy505
Copy link
Copy Markdown

@aldy505 aldy505 commented May 18, 2026

This PR

Provide AOT-compatible path for OFREP, maintains backward compatibility for users with dynamic code

Related Issues

Closes #600

Notes

Follow-up Tasks

How to test

@aldy505 aldy505 requested review from a team as code owners May 18, 2026 07:32
@github-actions github-actions Bot requested review from askpt and weyert May 18, 2026 07:33
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces Native AOT support for the OFREP provider by implementing typed evaluation methods and transitioning to source-generated JSON serialization. It also adds a dedicated AOT compatibility test project. Feedback focuses on resolving potential compilation errors related to dictionary type mismatches with the OpenFeature SDK and the use of .NET 5+ specific HttpContent methods in multi-targeted code. Additionally, there are recommendations to refactor duplicated validation and response mapping logic to improve maintainability.

Comment thread src/OpenFeature.Providers.Ofrep/Models/OfrepRequest.cs Outdated
Comment thread src/OpenFeature.Providers.Ofrep/Client/OfrepClient.cs Outdated
Comment thread src/OpenFeature.Providers.Ofrep/Client/OfrepClient.cs Outdated
Comment thread src/OpenFeature.Providers.Ofrep/Client/OfrepClient.cs Outdated
@askpt
Copy link
Copy Markdown
Member

askpt commented May 18, 2026

@aldy505 Could you please sign-off your commits? You can follow these instructions:

  1. Ensure you have a local copy of your branch by checking out the pull request locally via command line.
  2. In your local branch, run: git rebase HEAD~4 --signoff
  3. Force push your changes to overwrite the branch: git push --force-with-lease origin feat/aot-compatibility

aldy505 added 4 commits May 19, 2026 14:52
Closes open-feature#600

Provide AOT-compatible path for OFREP, maintains backward compatibility for users with dynamic code

Signed-off-by: Reinaldy Rafli <github@reinaldyrafli.com>
Signed-off-by: Reinaldy Rafli <github@reinaldyrafli.com>
Signed-off-by: Reinaldy Rafli <github@reinaldyrafli.com>
…standard compatibility

Signed-off-by: Reinaldy Rafli <github@reinaldyrafli.com>
@aldy505 aldy505 force-pushed the feat/aot-compatibility branch from 74a698c to f7f84de Compare May 19, 2026 07:52
Copy link
Copy Markdown
Member

@askpt askpt left a comment

Choose a reason for hiding this comment

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

I saw that you have a lot of "backward compatibility" in the OfrepClient. This client is not supposed to be used by the external consumers. I would encourage to remove the backwards compatibility and use only the AOT path.

Comment thread .github/workflows/ci.yml Outdated
Comment on lines +64 to +66
- name: OFREP AOT compatibility check
if: matrix.os == 'ubuntu-latest'
run: dotnet publish test/OpenFeature.Providers.Ofrep.AotCompatibility/OpenFeature.Providers.Ofrep.AotCompatibility.csproj -c Release -r linux-x64 --self-contained true -p:TreatWarningsAsErrors=true
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Have a look at: https://github.com/open-feature/dotnet-sdk/blob/main/.github/workflows/aot-compatibility.yml

We would prefer to have compatibility checks to all releases and machine types.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is done, though I'm not confident on enabling it for any other provider than Ofrep.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you consider moving this file to a single file app?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I don't have much experience on this. I thought you meant .csx file, then I found this post: https://learn.microsoft.com/en-us/dotnet/core/sdk/file-based-apps

Might take a while for this.

Signed-off-by: Reinaldy Rafli <github@reinaldyrafli.com>
@aldy505 aldy505 force-pushed the feat/aot-compatibility branch from 05fd71d to 4019d56 Compare May 29, 2026 01:35
aldy505 added 2 commits May 29, 2026 08:48
Signed-off-by: Reinaldy Rafli <github@reinaldyrafli.com>
Signed-off-by: Reinaldy Rafli <github@reinaldyrafli.com>
@aldy505
Copy link
Copy Markdown
Author

aldy505 commented May 29, 2026

@askpt Applied everything other than moving to single file app.

Copy link
Copy Markdown
Member

@askpt askpt left a comment

Choose a reason for hiding this comment

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

Added a couple of comments. Thanks for making the changes.

The single file can wait.

EvaluationContext? context, CancellationToken cancellationToken = default)
{
#if NET8_0_OR_GREATER
#if NET8_0_OR_GREATER
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
#if NET8_0_OR_GREATER
#if NET8_0_OR_GREATER


var response = await this._client.EvaluateFlag(flagKey, defaultValue,
context, cancellationToken).ConfigureAwait(false);
var response = await evaluate(flagKey, defaultValue, context, cancellationToken).ConfigureAwait(false);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why are you passing a function here instead of calling directly the method?

Comment on lines +20 to +23
/// <remarks>
/// This generic method is provided for backward compatibility.
/// For Native AOT scenarios, use the typed methods (EvaluateBooleanFlag, EvaluateStringFlag, etc.) instead.
/// </remarks>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this still valid?

Comment on lines +102 to +115
/// <summary>
/// Evaluates a flag value using the OFREP API. This generic method is provided for backward compatibility.
/// For Native AOT scenarios, use the typed methods (EvaluateBooleanFlag, EvaluateStringFlag, etc.) instead.
/// </summary>
/// <typeparam name="T">The type of the flag value.</typeparam>
/// <param name="flagKey">The key of the flag to evaluate.</param>
/// <param name="defaultValue">The default value to return if evaluation fails.</param>
/// <param name="context">The evaluation context.</param>
/// <param name="cancellationToken">A token to cancel the operation.</param>
/// <returns>The evaluated flag response.</returns>
/// <remarks>
/// This method delegates to the AOT-safe typed implementation for OFREP-supported value types.
/// Other generic types use the legacy reflection-based JSON path and are not AOT-safe.
/// </remarks>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems to be now fully native AOT compliant. This needs to be removed.

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.

OFREP AOT Compatibility

3 participants