rscgutils 2025.2412.724

dotnet add package rscgutils --version 2025.2412.724
                    
NuGet\Install-Package rscgutils -Version 2025.2412.724
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="rscgutils" Version="2025.2412.724" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="rscgutils" Version="2025.2412.724" />
                    
Directory.Packages.props
<PackageReference Include="rscgutils" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add rscgutils --version 2025.2412.724
                    
#r "nuget: rscgutils, 2025.2412.724"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package rscgutils@2025.2412.724
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=rscgutils&version=2025.2412.724
                    
Install as a Cake Addin
#tool nuget:?package=rscgutils&version=2025.2412.724
                    
Install as a Cake Tool

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="2024.2000.2000" 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/

Json2Class

If you have an additional json file, you can have a file from this

<ItemGroup>
	<AdditionalFiles Include="my.gen.json" />
</ItemGroup>

And you can have from the code


var json = System.Text.Json.JsonSerializer
    .Deserialize<GeneratedJson.my_gen_json>(MyAdditionalFiles.my_gen_json);

ArgumentNullException.ThrowIfNull( json );
Console.WriteLine( ":hosts"+json.AllowedHosts );

Memoization of function returns

Put _MemoPure and the return of the function will be memo-ized

public long Test_MemoPure()
{
    Console.WriteLine("calculating type");
    return this.GetType().ToString().GetHashCode();
}
public async Task<long> fib(long nr)
{
    await Task.Delay(1000);
    //Console.WriteLine("calculated value for " + nr);
    if (nr <= 1) return 1;
    if (nr == 2) return 2;
    return await fib(nr - 1) + await fib(nr - 1);
}

public async Task<long> fibonacci_MemoPure(long nr)
{
    if (nr <= 1) return 1;
    if (nr == 2) return 2;
    await Task.Delay(1000);
    return await fibonacci(nr - 1) + await fibonacci(nr - 1);

}

And call

fibTest f = new();
Console.WriteLine("first time :" + f.Test());
Console.WriteLine("second time :" + f.Test());

Console.WriteLine(DateTime.Now.ToString("mm_ss"));
Console.WriteLine("no memo :"+await f.fib(5));
Console.WriteLine(DateTime.Now.ToString("mm_ss"));
Console.WriteLine("memo :" + await f.fibonacci(5));
Console.WriteLine(DateTime.Now.ToString("mm_ss"));
Console.WriteLine("FAST memo :" + await f.fibonacci(5));
Console.WriteLine(DateTime.Now.ToString("mm_ss"));


More Roslyn Source Code Generators

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

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2025.2412.724 198 12/24/2025
2024.2000.2000 332 3/15/2024
2024.1859.1955 282 3/12/2024
2024.1858.1957 283 3/15/2024
2024.1858.1931 285 3/12/2024
2024.1857.1858 250 3/12/2024
2023.914.2016 333 9/14/2023
2023.827.1021 453 8/27/2023
2023.827.904 361 8/27/2023
2023.827.621 320 8/27/2023
2023.826.1704 343 8/27/2023
2023.514.835 341 5/14/2023
2023.502.835 345 5/2/2023
2023.501.2230 256 5/1/2023
2023.501.951 289 5/1/2023
2023.8.26.1704 341 8/26/2023