Rop.ProxyGenerator.Annotations 1.0.16

There is a newer version of this package available.
See the version list below for details.
dotnet add package Rop.ProxyGenerator.Annotations --version 1.0.16
NuGet\Install-Package Rop.ProxyGenerator.Annotations -Version 1.0.16
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Rop.ProxyGenerator.Annotations" Version="1.0.16" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Rop.ProxyGenerator.Annotations --version 1.0.16
#r "nuget: Rop.ProxyGenerator.Annotations, 1.0.16"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Rop.ProxyGenerator.Annotations as a Cake Addin
#addin nuget:?package=Rop.ProxyGenerator.Annotations&version=1.0.16

// Install Rop.ProxyGenerator.Annotations as a Cake Tool
#tool nuget:?package=Rop.ProxyGenerator.Annotations&version=1.0.16

Rop.ProxyGenerator

Features

Rop.ProxyGenerator is a source generator package to automatic proxy of interfaces. It can be used to provide Aspect Oriented Programming to c# via a "proxy".

The package is published in nuget as 'Rop.ProxyGenerator'

Example:

I want to add to any winform control a "IControlValue" standard interface.

public interface IControlValue<T>
  {
    event EventHandler ControlValueChanged;
    [Exclude]
    T ControlValue { get; set; }
  }

The interface has a common implementation but C# can't allow multiple inheritance.

To allow inject IControlValue logic to any winform control we derive a control with this syntax:

 [ProxyOf("IControlValue<int>", nameof(_controlValueProxy))]
    public partial class TextBoxValue : TextBox, IControlValue<int>
    {
        private readonly IControlValue<int> _controlValueProxy;
        public TextBoxValue()
        {
            _controlValueProxy = new TextBoxValueAop(this);
        }
        private class TextBoxValueAop : ControlValueAop<TextBoxValue, int>
        {
            public TextBoxValueAop(TextBoxValue parent) : base(parent){}
        }
    }

The constructor creates the adapted logic to our class. That logic will be automaticly injected to code via rop.proxygenerator. The source generator.

The generated code will be a proxy for each IControlValue member.

// Autogenerated code for Proxy class
	public partial class TextBoxValue
	{
            public event EventHandler ControlValueChanged{ 
                add=>_controlValueProxy.ControlValueChanged+=value; 
                remove=>_controlValueProxy.ControlValueChanged-=value;
            }
	    public virtual void OnControlValueChanged()
            {
                _controlValueProxy.OnControlValueChanged();
            }
		
        // Symbol 'ControlValue' excluded
	}

I can "exclude" a member to force his declaration via attributes. In this case. "ControlValue" depends of the type of the control. So, I must hard code in my class

public partial class TextBoxValue{
    public virtual int ControlValue
        {
            get => int.TryParse(base.Text, out int v) ? v : -1;
            set => base.Text = value.ToString();
        }
}

The ASPECT code to incorporate as proxy is derived from a abstract common logic of type ControlValueAOP

public abstract class ControlValueAop<C, T> : IControlValue<T> where C : Control, IControlValue<T>
  {
    public C Parent { get; }

    public event EventHandler ControlValueChanged;
    public virtual void OnControlValueChanged()
    {
      ControlValueChanged?.Invoke(this.Parent, EventArgs.Empty);
    }
    public virtual T ControlValue
    {
      get => this.Parent.ControlValue;
      set => this.Parent.ControlValue = value;
    }
    protected ControlValueAop(C parent)
    {
      this.Parent = parent;
    }
  }

Rop.ProxyGenerator.Annotations

Attibutes to decorate a class to contain a proxy.

[AttributeUsage(AttributeTargets.Class)]
public class ProxyOfAttribute:Attribute
{
...
    public ProxyOfAttribute(Type interfacename, string fieldname,string[] exclude=null)
    {
	...
    }
}

Attibutes to include other attributes defined in an interface

public class IncludeNextAttributesAttribute : System.Attribute {}

Attribute to Exclude a Member

 public class ExcludeAttribute : Attribute { }

Attibutes to Override Members

public class OverrideNewAttribute : Attribute { }
public class OverrideNoBaseAttribute : Attribute { }
public class OverrideWithPreBaseAttribute : Attribute { }
public class OverrideWithPostBaseAttribute : Attribute { }

Attributes to force Explicit Implementation of Proxy Interface

public class ExplicitAttribute : Attribute { }
public class ExplicitOverrideNoBaseAttribute : Attribute { }
public class ExplicitOverrideWithPreBaseAttribute : Attribute { }
public class ExplicitOverrideWithPostBaseAttribute : Attribute { }

Rop.ProxyGenerator

The source generator that create the proxy as partial class. Must be included as:

  • OutputItemType="Analyzer"
  • ReferenceOutputAssembly="false"

(C)2022 Ramón Ordiales Plaza

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages (13)

Showing the top 5 NuGet packages that depend on Rop.ProxyGenerator.Annotations:

Package Downloads
Rop.Winforms.Basic

Helper classes for Winforms

Rop.Winforms.KeyValueListComboBox

Create KeyValue ListBox and ComboBox

Rop.Winforms.ColorSets

Helper classes for GDI+ Colors and KeyValueControls

Rop.Winforms.ListComboBox

Create compatible Items form ListBox and ComboBox

Rop.Winforms.ControlValue

Create Control with value

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.20 169 7/8/2023
1.0.19 120 7/8/2023
1.0.18 122 6/30/2023
1.0.17 124 6/30/2023
1.0.16 126 6/29/2023
1.0.14 277 1/14/2023
1.0.13 1,253 6/16/2022
1.0.12 367 6/16/2022
1.0.11 368 6/16/2022
1.0.10 364 6/15/2022
1.0.9 359 6/15/2022
1.0.8 363 6/15/2022
1.0.7 371 6/15/2022
1.0.6 360 6/15/2022
1.0.5 376 6/14/2022
1.0.4 372 6/7/2022
1.0.3 363 6/7/2022
1.0.2 361 6/6/2022
1.0.1 374 6/3/2022