Skip to main content

Hardcoded.NET by Emanuele Onnivello

NuGet / site data​

Nuget GitHub last commit GitHub Repo stars

Details​

Info​

info

Name: Hardcoded.NET

Turn 'hardcoding' into a performance feature. Ironic, but accurate. It is a source generator that leverages Roslyn to convert resources into mapped constants.

Author: Emanuele Onnivello

NuGet: https://www.nuget.org/packages/Hardcoded.NET/

You can find more details at https://codeberg.org/wave/Hardcoded.NET

Source: https://codeberg.org/wave/Hardcoded.NET

Author​

note

Emanuele Onnivello Alt text

Original Readme​

note

About​

note

Generating compile-time SQL string constants from .sql files

How to use​

Example (source csproj, source files)​

This is the CSharp Project that references Hardcoded.NET

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Hardcoded.NET" Version="0.2.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<AdditionalFiles Include="PersonQueries.sql" />
</ItemGroup>

<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>

</Project>

Generated Files​

Those are taken from $(BaseIntermediateOutputPath)\GX

namespace HardcodedDemo;

internal static partial class PersonQueries
{
/// <summary>
/// Retrieves a person by identifier
/// </summary>
internal const string GetPersonById = @"SELECT Id, Name
FROM Person
WHERE Id = @Id";

}

Useful​

Download Example (.NET C#)​

Share Hardcoded.NET​

https://ignatandrei.github.io/RSCG_Examples/v2/docs/Hardcoded.NET

Category "FilesToCode" has the following generators:​

1 Chorn.EmbeddedResourceAccessGenerator Nuget GitHub Repo stars 2024-01-21

2 corecraft Nuget GitHub Repo stars 2024-02-17

3 Datacute.EmbeddedResourcePropertyGenerator Nuget GitHub Repo stars 2024-11-03

4 DotnetYang Nuget GitHub Repo stars 2024-06-29

5 EmbedResourceCSharp Nuget GitHub Repo stars 2023-04-16

6 Hardcoded.NET Nuget GitHub Repo stars 2026-12-23

7 kli.Localize Nuget GitHub Repo stars 2025-10-01

8 LingoGen Nuget GitHub Repo stars 2024-02-23

9 Maestria.TypeProviders Nuget GitHub Repo stars 2026-04-09

10 MagicConstants Nuget GitHub Repo stars 2026-09-04

11 NFH.FileEmbed Nuget GitHub Repo stars 2025-08-08

12 NotNotAppSettings Nuget GitHub Repo stars 2024-01-26

13 Pinecone.TypedPath Nuget GitHub Repo stars 2026-08-24

14 Podimo.ConstEmbed Nuget GitHub Repo stars 2023-04-16

15 ResXGenerator Nuget GitHub Repo stars 2023-10-02

16 RSCG_JSON2Class Nuget GitHub Repo stars 2024-02-29

17 RSCG_Sql Nuget GitHub Repo stars 2026-11-09

18 RSCG_Utils Nuget GitHub Repo stars 2023-04-16

19 Slang.Net Nuget GitHub Repo stars 2026-09-11

20 Strings.ResourceGenerator Nuget GitHub Repo stars 2025-07-06

21 SvgIconGenerator Nuget GitHub Repo stars 2026-04-04

22 ThisAssembly_Resources Nuget GitHub Repo stars 2023-09-16

23 ThisAssembly.Strings Nuget GitHub Repo stars 2024-07-21

24 TypedPaths Nuget GitHub Repo stars 2026-04-01

25 Weave Nuget GitHub Repo stars 2024-01-27

See category​

FilesToCode