The HawkN.Iso.Currencies project uses a Source Generator to generate currency code files based on Unicode CLDR data.
- Open the
HawkN.Iso.Currencies.csprojfile. - Enable code generation by setting the following property:
<GenerateCurrencyFiles>true</GenerateCurrencyFiles>- Save the changes.
- Rebuild the solution.
- Review the generated files:
CurrencyCode.csLocalCurrencyDatabase.cs
- After verification, disable generation:
<GenerateCurrencyFiles>false</GenerateCurrencyFiles>- Save changes and rebuild the solution again.
Generation is disabled by default to avoid unstable builds, network access during CI, and to keep builds reproducible.
Currency data is sourced exclusively from Unicode CLDR.
ISO XML files, SIX Group resources, and third-party JSON repositories are not used.
-
Currency and country mapping
supplementalData.xml
https://raw.githubusercontent.com/unicode-org/cldr//common/supplemental/supplementalData.xml -
English currency names and symbols
en.xml
https://raw.githubusercontent.com/unicode-org/cldr//common/main/en.xml
Replace <release> with the desired CLDR release version (for example: release-48).
- Update the CLDR version if needed:
<CldrVersion>release-48</CldrVersion>- Temporarily enable CLDR downloads and code generation:
<DownloadCldrFiles>true</DownloadCldrFiles>
<GenerateCurrencyFiles>true</GenerateCurrencyFiles>- Rebuild the project.
- Verify that:
- CLDR XML files were downloaded
CurrencyCode.csandLocalCurrencyDatabase.cswere regenerated
- Commit the generated changes to the repository.
- Disable the flags again:
<DownloadCldrFiles>false</DownloadCldrFiles>
<GenerateCurrencyFiles>false</GenerateCurrencyFiles>- Rebuild the project once more.
- Historical currencies are excluded. Only currently active currencies from CLDR are included.
- All data is distributed under the Unicode License Agreement, which is MIT-compatible.
- The final NuGet package does not contain XML files or runtime parsers.
- Code generation is intended to be run manually and committed, not executed on every build.