MixedIL.Fody 0.1.6

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

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

MixedIL.Fody

Build NuGet package .net License
Icon

This is an add-in for Fody which allows you to impliment C# method by IL code.


Installation

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

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

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


Usage

  1. Write a method stub in a C# project with keyword extern and an attribute provided in MixedIL called MixedILAttribute
using MixedIL;

namespace System;

public class ObjectHelper
{
    [MixedIL]
    public static extern bool AreSame<T>(ref T a, ref T b);
}
  1. Then create a .il file in the the C# project and implement the method in il code. C# dll
.class public abstract auto ansi sealed beforefieldinit System.ObjectHelper
{
    .method public hidebysig static bool AreSame<T>(!!T& a, !!T& b) cil managed aggressiveinlining
    {
        .maxstack 2
        ldarg.0
        ldarg.1
        ceq
        ret
    }
}
  1. Compile the project and that's it.
NOTE:
  • The method signature and declaring type should be the same.
  • Only il method body will be injected into the assembly file, other parts like attributes in il code won't. You can just write all the other parts using C# code.

Examples


Comparison with InlineIL.Fody

InlineIL.Fody is a remarkable fody add-in which lets you inject IL instructions by calling normal static C# methods. While there are some differences, so you can choose based on your requirement.

  • Basically, in most cases you can use InlineIL, which is more friendly to C# developers.
  • MixedIL is more flexible and less restrictive, since pure IL code will be written.
    For instance, you can invoke backing field of a property without setter by pure IL, like this:
    stfld string [System.Runtime]System.Reflection.AssemblyKeyNameAttribute::'<KeyName>k__BackingField'
    see example code.
    However, up to now, you will get compile error if you would like to implement it using InlineIL.
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 was computed. 
.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

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.6 239 10/20/2023
0.1.5 105 10/19/2023
0.1.4 121 10/14/2023
0.1.3 396 6/3/2022
0.0.9 381 6/3/2022
0.0.8 380 6/1/2022
0.0.7 391 5/31/2022
0.0.6 385 5/31/2022
0.0.4 372 5/31/2022