RSCG_NameGenerator by Andrei Ignat
Nuget / site data
Details
Info
Name: RSCG_NameGenerator
Generates uniqe names for release
Author: Andrei Ignat
NuGet: https://www.nuget.org/packages/RSCG_NameGenerator/
You can find more details at https://github.com/ignatandrei/NameGenerator/
Original Readme
NameGenerator
Generator of names for an assembly / product release . Generates names for {adjective}-{name} or {adjective-name-city}
The fact that is a Roslyn Code Generator ensures that you can use it in your projects without any additional dependencies - and get rid of him !
Usage
Add to the .csproj file:
<ItemGroup>
<PackageReference Include="RSCG_NameGenerator" Version="2024.26.8.2002" >
<OutputItemType>Analyzer</OutputItemType>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</PackageReference>
</ItemGroup>
<!-- optional -->
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
Then, in the code, you can use the following code:
using Generated.TestNameGenerator;
//by just putting here
//you will not deploy the dll when you deploy the project
//name are generated in the code source
Console.WriteLine($"Name:{TheAssemblyInfo.GeneratedName}");
Console.WriteLine($"Nice:{TheAssemblyInfo.GeneratedNameNice}");
Console.WriteLine($"Small:{TheAssemblyInfo.GeneratedNameSmall}");
More examples
Please see https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG for a list of examples of Roslyn Source Code Generators
Enjoy!
About
Generating unique names for assemblies
How to use
Example ( source csproj, source files )
- CSharp Project
- Program.cs
This is the CSharp Project that references RSCG_NameGenerator
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="RSCG_NameGenerator" Version="2024.26.8.2002" >
<OutputItemType>Analyzer</OutputItemType>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</PackageReference>
</ItemGroup>
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
</Project>
This is the use of RSCG_NameGenerator in Program.cs
using Generated.TestNameGenerator;
//by just putting here
//you will not deploy the dll when you deploy the project
//name are generated in the code source
Console.WriteLine($"Name:{TheAssemblyInfo.GeneratedName}");
Console.WriteLine($"Nice:{TheAssemblyInfo.GeneratedNameNice}");
Console.WriteLine($"Small:{TheAssemblyInfo.GeneratedNameSmall}");
//if you want to generate a new name every time you run the app
//put in the csproj
//<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
//but the dll will be deployed with the app
//Console.WriteLine(NameGenerator.NameGeneratorData.Generate().UniqueNameLong);
Generated Files
Those are taken from $(BaseIntermediateOutputPath)\GX
- TheAssemblyInfo.g.cs
// <auto-generated/>
namespace Generated.TestNameGenerator
{
public static class TheAssemblyInfo
{
public const string AssemblyName = "TestNameGenerator";
public const string GeneratedNameNice = "Isaac Bashevis Singer is feeling present in Manila";
public const string GeneratedNameSmall = "present-Isaac Bashevis Singer";
public const string GeneratedName = "present-Isaac Bashevis Singer-Manila";
}
}
Usefull
Download Example (.NET C# )
Share RSCG_NameGenerator
https://ignatandrei.github.io/RSCG_Examples/v2/docs/RSCG_NameGenerator