Skip to content

Roslyn Source Code Generator - transform static classes into instances and interfaces

License

Notifications You must be signed in to change notification settings

ignatandrei/RSCG_Static

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

        public Type GenerateInterfaceFromDate()=>typeof(DateTime);

and the properties of the classes will be generated into interfaces and you can write:

//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

About

Roslyn Source Code Generator - transform static classes into instances and interfaces

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages