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


<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


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());



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

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;
	}

}
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