Inspired by Code; This is a project that contains utility code that don't belong together in a monolithic library. However, as opposed to Code, this repository has no source generators or roslyn analyzers to add these files. Instead, these are configurations which can be applied and synced to multiple projects simultaneously. This means that there is no need to add references, or figure out whether some type is needed or not, as all of them are added automatically.
- Download the .NET 9 SDK.
- Download/clone the repository:
git clone https://github.com/Emik03/Emik.Morsels.git
- Copy-paste Directory.Build.local.props.template and name the new duplicate
Directory.Build.local.props
. - Modify the PropertyGroup of
Directory.Build.local.props
, which contains absolute paths that are system-dependent. - Execute this command on Windows or this command on Mac/Linux with each Emik.Morsels project as the working directory to symlink everything together.
- You can alternatively have a folder for
Emik.Morsels
projects, and all projects simply reside in nested folders. This way, you only need to set up the symlinks a single time on the root folder since search scope applies to parent folders as well.
- You can alternatively have a folder for
The following block contains officially maintained projects that implement Emik.Morsels:
Of course, if you add every type, it often means that a lot of unnecessary code is shipped along with your assembly, which is especially not ideal if you only require a single function from the set of all types. To counteract this, an additional dependency is placed on Absence.Fody which automatically looks for unused types that aren't explicitly marked as either CompilerGeneratedAttribute or ImplicitlyUsedAttribute. As a result, any unused types outside of Emik.Morsels within the project will also be discarded during compile-time.
Emik.Morsels currently supports the following frameworks:
- .NET Framework: 2.0 - 4.8.1
- .NET Standard: 1.0 - 2.1
- .NET Core: 1.0 - 3.1
- .NET: 5.0 - 9.0
Different scripts and configurations within this repository will act accordingly to the current framework, such as polyfills, or by taking advantage of .NET 6+'s static abstract
features.
Emik.Morsels also contains an IL-modified version of the .NET Framework 3.5 reference assembly. This is a reference assembly that has a weaved System.Type.op_Equality
, allowing you to use record types without Emik.Net20Records.
This method is attributed with InlineAttribute
to ensure removal to the modified reference, changing it to a simple ceq
((object)lh == rh
) instruction.
The code that was used to generate this assembly can be found here.
There are also symlinks for System.dll
and System.Numerics.dll
that both point to said standard library, meant as a silly workaround for expecting those two files when compiling in F#, since System.Numerics
doesn't exist in .NET 3.5.
Despite the types being marked internal, all scripts here act as an evolving API. As a result, feedback is much more likely to be applied as breaking changes can be more easily made without breaking preexisting code.
Issues and pull requests are welcome to help this repository be the best it can be.
This repository — which includes every source file separately — fall under the MPL-2 license.
You may copy individual or multiple source files, granted that you keep the copyright license, and disclose the source back to this repository.