Skip to main content

RSCG_Utils by Ignat Andrei

NuGet / site data

Nuget GitHub last commit GitHub Repo stars

Details

Info

Original Readme

note

RSCG_Utils

Roslyn Source Code Generators Utils

pack to nuget

pack to nuget

Usage

Additional Files

Allow you to see additional files directly as C# const. For this, please add some .gen. files to the project.

In your csproj

<ItemGroup>
<PackageReference Include="rscgutils" Version="2023.502.835" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="Second.gen.txt" />
<AdditionalFiles Include="first.gen.txt" />
<AdditionalFiles Include="test\Afirst.gen.txt" />
<AdditionalFiles Include="sql/**/*" />
</ItemGroup>

In the code

//see https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/raw-string
string x= MyAdditionalFiles.Second_gen_txt;

To debug, you can add into the .csproj

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

More details at http://msprogrammer.serviciipeweb.ro/2023/05/08/file-to-csharp-const/

More Roslyn Source Code Generators

You can find more RSCG with examples at Roslyn Source Code Generators

About

note

Add files as C# consts

How to use

Example (source csproj, source files)

This is the CSharp Project that references RSCG_Utils

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

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

<ItemGroup>
<PackageReference Include="rscgutils" Version="2023.514.835" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />

</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="data.gen.txt" />
</ItemGroup>

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


</Project>

Generated Files

Those are taken from $(BaseIntermediateOutputPath)\GX


public static partial class MyAdditionalFiles
{
//https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/raw-string
public const string data_gen_txt = """"""""""
This is a data
That you will retrieve
as C# const
"""""""""";
}

Useful

Download Example (.NET C#)

Share RSCG_Utils

https://ignatandrei.github.io/RSCG_Examples/v2/docs/RSCG_Utils

aaa

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 kli.Localize Nuget GitHub Repo stars 2025-10-01

7 LingoGen Nuget GitHub Repo stars 2024-02-23

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

9 NotNotAppSettings Nuget GitHub Repo stars 2024-01-26

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

11 ResXGenerator Nuget GitHub Repo stars 2023-10-02

12 RSCG_JSON2Class Nuget GitHub Repo stars 2024-02-29

13 RSCG_Utils Nuget GitHub Repo stars 2023-04-16

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

15 ThisAssembly_Resources Nuget GitHub Repo stars 2023-09-16

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

17 Weave Nuget GitHub Repo stars 2024-01-27

See category

FilesToCode