Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ignatandrei/RSCG_Static
Roslyn Source Code Generator - transform static classes into instances and interfaces
https://github.com/ignatandrei/RSCG_Static
Last synced: about 1 month ago
JSON representation
Roslyn Source Code Generator - transform static classes into instances and interfaces
- Host: GitHub
- URL: https://github.com/ignatandrei/RSCG_Static
- Owner: ignatandrei
- License: mit
- Created: 2021-08-30T22:08:40.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-23T18:02:38.000Z (over 1 year ago)
- Last Synced: 2024-11-01T14:06:53.341Z (about 1 month ago)
- Language: C#
- Size: 55.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- RSCG_Examples - https://github.com/ignatandrei/RSCG_Static
README
# RSCG_Static
Roslyn Source Code Generator - transform static classes into instances and interfaces
More, there is a MakeNew static method created to can have DI.
Just put a function like this ( example for System.DateTime)
```csharp
public Type GenerateInterfaceFromDate()=>typeof(DateTime);
```and the properties of the classes will be generated into interfaces and you can write:
```csharp
//for DI, register
//ISystem_DateTime with transient for new clsSystem_DateTime()
Console.WriteLine("Hello World!");
ISystem_DateTime dateStatic = recSystem_DateTime.MakeNew();//static
ISystem_DateTime dateVar = new clsSystem_DateTime(); //variable = realConsole.WriteLine(dateStatic.Now.Second);
Console.WriteLine(dateVar.Now.Second);
await Task.Delay(10 * 1000);
Console.WriteLine(dateStatic.Now.Second);
Console.WriteLine(dateVar.Now.Second);
```# More Roslyn Source Code Generators
You can find more RSCG with examples at [Roslyn Source Code Generators](https://ignatandrei.github.io/RSCG_Examples/v2/)