Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

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 = real

Console.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/)