Skip to content

Commit

Permalink
Add Tips section for AOT enabled builds (dotnet#40770)
Browse files Browse the repository at this point in the history
* Add Tips section for AOT enabled builds

* Change the links from absolute to relative

* add file extension
  • Loading branch information
tarekgh authored May 6, 2024
1 parent da8fa31 commit 76ffdb2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/core/extensions/options-validation-generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ The following code exemplifies how to bind the configuration section to the opti

:::code source="snippets/configuration/console-validation-gen/Program.cs":::

> [!TIP]
> When AOT compilation is enabled by including `<PublishAot>true</PublishAot>` in the _.csproj_ file, the code might generate warnings such as [IL2025](../deploying/trimming/trim-warnings/il2025.md) and [IL3050](../deploying/native-aot/warnings/il3050.md). To mitigate these warnings, it's recommended to use the configuration source generator. To enable the configuration source generator, add the property `<EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>` to the project file.
By leveraging compile-time source generation for options validation, you can generate performance-optimized validation code and eliminate the need for reflection, resulting in smoother AOT-compatible app building. The following code demonstrates how to use the options validation source generator:

:::code source="snippets/configuration/console-validation-gen/ValidateSettingsOptions.cs":::
Expand Down

0 comments on commit 76ffdb2

Please sign in to comment.