Emik.Net20Records 2.0.0

Additional Details

Refer to https://github.com/Emik03/Emik.Net20Records/#deprecated for a better method that doesn't involve a hard dependency. If you are using this library already and are happy enough as is, then feel free to continue using it anyway as the library itself is fine as is and perfectly usable, though it will no longer be maintained as it's completely finished.

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

// Install Emik.Net20Records as a Cake Tool
#tool nuget:?package=Emik.Net20Records&version=2.0.0

Emik.Net20Records

NuGet License

Adds C# 9/10's record/record struct support for .NET Framework 2, 3, and 3.5.


Deprecated

As of January 10th 2023, this library will no longer be maintained and is considered obsolete in favor of a better alternative:

  • Add InlineIL.Fody as a dependency, setup of Fody is required.

  • Download this file; a modified version of the .NET Framework 3.5 binary.

  • Reference this binary in your .csproj, or Directory.Build.targets:

<ItemGroup Condition="'$(TargetFramework)' == 'net35'">
  <Reference Include="mscorlib" Aliases="global, ms" Private="false" HintPath="$(SharedPath)Emik.Morsels/References/mscorlib.dll" />
</ItemGroup>

Refer to the prerequisite, then compile.

For more information on how or why this works, click here.


Prerequisite

This library intentionally leaves out System.Runtime.CompilerServices.IsExternalInit to be able to be better integrated with other excellent polyfilling libraries such as Theraot.Core. Either use a package like Manual Roemer's IsExternalInit, or define your own within the project:

using System.ComponentModel;

namespace System.Runtime.CompilerServices;

/// <summary>Reserved to be used by the compiler for tracking metadata. This class should not be used by developers in source code.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static class IsExternalInit
{
}

Description

Record types, introduced in C# 9 and 10 are a fantastic feature that allows for easily creating data types with lots of overriden methods that lift a lot of heavy boilerplate out of classes. The feature was originally targetted for .NET 5, but can be used in previous frameworks by polyfilling System.Runtime.CompilerServices.IsExternalInit.

However, prior to .NET Framework 4, the System.Type.op_Equality and System.Type.op_Inequality methods didn't exist. Roslyn still expects them to exist, and will therefore throw an error that this method is missing.

This library adds record and record struct functionality for old .NET Frameworks by create a wrapper class Type that inherits the original, and polyfilling the required op_Equality and op_Inequality static methods by calling System.Type.Equals(Type) which Roslyn scans for.


Contribute

As with most GitHub repositories, you can contribute by:

Product Compatible and additional computed target framework versions.
.NET Framework net20 is compatible.  net35 was computed.  net40 was computed.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 2.0

    • No dependencies.

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
2.0.0 497 7/18/2022
1.0.0 491 3/26/2022