| name | MagicConstants |
| nuget | https://www.nuget.org/packages/MagicConstants/ |
| link | https://github.com/LieselThuriot/MagicConstants |
| author | Liesel Thuriot |
Generates constants from files to return contents. It has extension for routes and more for ASP.NET projects.
This is how you can use MagicConstants .
The code that you start with is
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
<PropertyGroup>
<MagicConstantsVisibility>internal</MagicConstantsVisibility>
<MagicConstantsRoutes>false</MagicConstantsRoutes>
<MagicConstantsFunctions>false</MagicConstantsFunctions>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MagicConstants" Version="1.0.0-preview-22" />
<AdditionalFiles Include="MyFolderToShow/**/*.json" MagicClass="Assets" />
</ItemGroup>
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
</Project>
The code that you will use is
using FolderToCode; Console.WriteLine(Assets.MyFolderToShow_en_a_json); Console.WriteLine(Assets.MyFolderToShow_ro_a_json);
The code that is generated is
namespace FolderToCode
{
public static partial class Assets
{
internal const string MyFolderToShow_en_a_json = @"";
}
}
namespace FolderToCode
{
public static partial class Assets
{
internal const string MyFolderToShow_ro_a_json = @"";
}
}
Code and pdf at
https://ignatandrei.github.io/RSCG_Examples/v2/docs/MagicConstants