RSCG – DudNet
RSCG – DudNet
name | DudNet |
nuget | https://www.nuget.org/packages/Jwshyns.DudNet/ |
link | https://github.com/jwshyns/DudNet |
author | jwshyns |
Generate proxy classes for the principal classes
This is how you can use DudNet .
The code that you start with is
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 | < Project Sdk = "Microsoft.NET.Sdk" > < PropertyGroup > < OutputType >Exe</ OutputType > < TargetFramework >net7.0</ TargetFramework > < ImplicitUsings >enable</ ImplicitUsings > < Nullable >enable</ Nullable > </ PropertyGroup > < ItemGroup > < PackageReference Include = "Jwshyns.DudNet" Version = "1.2.0" /> </ ItemGroup > < PropertyGroup > < EmitCompilerGeneratedFiles >true</ EmitCompilerGeneratedFiles > < CompilerGeneratedFilesOutputPath >$(BaseIntermediateOutputPath)\GX</ CompilerGeneratedFilesOutputPath > </ PropertyGroup > </ Project > |
The code that you will use is
1 2 3 4 5 6 7 8 | using DudNetDemo; var p = new Person(); var p1= new PersonProxy(p); p1.FirstName = "John" ; p1.LastName = "Doe" ; Console.WriteLine(p.FullName()); Console.WriteLine(p1.FullName()); |
01 02 03 04 05 06 07 08 09 10 11 12 13 14 | using DudNet.Attributes; using System.Runtime.CompilerServices; namespace DudNetDemo; [ProxyService] public partial class Person : IPerson { public string ? FirstName { get ; set ; } public string ? LastName { get ; set ; } public string FullName() { return FirstName + " " + LastName; } } |
The code that is generated is
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | using System.Runtime.CompilerServices; using DudNet.Attributes; using System.Runtime.CompilerServices; namespace DudNetDemo; /// <inheritdoc cref="IPerson"/> public partial class PersonDud : IPerson { public string ? FirstName { get { return ( string ?) default ; } set { } } public string ? LastName { get { return ( string ?) default ; } set { } } public string FullName() { return ( string ) default ; } } |
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | using System.Runtime.CompilerServices; using DudNet.Attributes; using System.Runtime.CompilerServices; namespace DudNetDemo; /// <inheritdoc cref="IPerson"/> public partial class PersonProxy : IPerson { private readonly IPerson _service; public string ? FirstName { get { Interceptor(); get_FirstNameInterceptor(); return _service.FirstName; } set { Interceptor(); set_FirstNameInterceptor(value); _service.FirstName = value; } } public string ? LastName { get { Interceptor(); get_LastNameInterceptor(); return _service.LastName; } set { Interceptor(); set_LastNameInterceptor(value); _service.LastName = value; } } public string FullName() { Interceptor(); FullNameInterceptor(); return _service.FullName(); } partial void Interceptor([CallerMemberName] string callerName = null ); partial void get_FirstNameInterceptor(); partial void set_FirstNameInterceptor( string ? value); partial void get_LastNameInterceptor(); partial void set_LastNameInterceptor( string ? value); partial void FullNameInterceptor(); } |
Code and pdf at
https://ignatandrei.github.io/RSCG_Examples/v2/docs/DudNet
Leave a Reply