InterfaceBaseInvoke.Fody 0.1.3

dotnet add package InterfaceBaseInvoke.Fody --version 0.1.3
NuGet\Install-Package InterfaceBaseInvoke.Fody -Version 0.1.3
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="InterfaceBaseInvoke.Fody" Version="0.1.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add InterfaceBaseInvoke.Fody --version 0.1.3
#r "nuget: InterfaceBaseInvoke.Fody, 0.1.3"
#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 InterfaceBaseInvoke.Fody as a Cake Addin
#addin nuget:?package=InterfaceBaseInvoke.Fody&version=0.1.3

// Install InterfaceBaseInvoke.Fody as a Cake Tool
#tool nuget:?package=InterfaceBaseInvoke.Fody&version=0.1.3

InterfaceBaseInvoke.Fody

Build NuGet package .net License
Icon

This is an add-in for Fody which contains a workaround for Interface Default Implementation Base Invocation.
The feature has not been implemented by C# team yet.
The status for it can be seen in https://github.com/dotnet/csharplang/issues/2337



Installation

  • Include the Fody and InterfaceBaseInvoke.Fody NuGet packages with a PrivateAssets="all" attribute on their <PackageReference /> items. Installing Fody explicitly is needed to enable weaving.

    <PackageReference Include="Fody" Version="..." PrivateAssets="all" />
    <PackageReference Include="InterfaceBaseInvoke.Fody" Version="..." PrivateAssets="all" />
    
  • If you already have a FodyWeavers.xml file in the root directory of your project, add the <InterfaceBaseInvoke /> tag there. This file will be created on the first build if it doesn't exist:

    <?xml version="1.0" encoding="utf-8" ?>
    <Weavers>
      <InterfaceBaseInvoke />
    </Weavers>
    

See Fody usage for general guidelines, and Fody Configuration for additional options.

Usage

Call the extension method Base<T> to cast an object to one of its interfaces, and then call a method or a property.
Just like:

  • var result = this.Base<Interface>().Method(1, "test");
  • var value = this.Base<Interface>().Property

Examples

  • An example project

  • Unit tests can also serve as examples of API usage. See test cases for valid usage and invalid usage.

  • Basic example:

    public interface IService
    {
        int Property => 5;
        void Method() => Console.WriteLine("Calling...");
    }
    
    public class Service : IService
    {
        // call the implementation of interface's property
        public int Property => this.Base<IService>().Property + 1;
    
        public void Method()
        {
            Console.WriteLine("Before call method");
            // call the implementation of interface's method
            this.Base<IService>().Method();
            Console.WriteLine("After call method");
        }
    }
    
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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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.1

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.3 249 10/20/2023
0.1.1 135 10/13/2023
0.1.0 138 6/3/2023
0.0.9 425 6/2/2022
0.0.7 393 8/22/2021
0.0.6 331 8/20/2021
0.0.5 285 8/20/2021
0.0.4 337 8/19/2021
0.0.3 313 8/18/2021
0.0.2 315 8/18/2021
0.0.1 313 8/18/2021