Inspired by Code; This is a project that contains utility code that don't belong together in a monolithic library. However, as oppose 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/clone the repository:
git clone https://github.com/Emik03/Emik.Morsels.git
- Modify the PropertyGroup of Directory.Build.local.props, which contains absolute paths that are system-dependent.
- Add symbolic links to stylecop.json, Directory.Build.props, Directory.Build.targets, and Directory.Build.local.props for each project that references Emik.Morsels.
- You can alternatively have a folder for
Emik.Morsels
projects, where the root contains these four files, and all projects simply reside in nested folders. This way, you only need to set up the symlinks a single time.
- You can alternatively have a folder for
- Windows:
mklink stylecop.json <STYLECOP_PATH>
mklink Directory.Build.props <PROPS_PATH>
mklink Directory.Build.targets <TARGETS_PATH>
mklink Directory.Build.local.props <LOCAL_PROPS_PATH>
- Mac/Linux:
ln -s stylecop.json <STYLECOP_PATH>
ln -s Directory.Build.props <PROPS_PATH>
ln -s Directory.Build.targets <TARGETS_PATH>
ln -s Directory.Build.local.props <LOCAL_PROPS_PATH>
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 has framework-dependent dependencies to accomodate the following purposes:
Framework | Purpose |
---|---|
.NET Framework 3.5 | Keep Talking and Nobody Explodes / Unity 2017.4.22f1 |
.NET Framework 4.5.2 | Celeste / Everest |
.NET Standard 2.0 | Fody / General |
.NET Standard 2.1 / NET Core | General |
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. If you do not own the products, you can simply target another framework. (e.g. .NET Framework 4.5.1)
Anything span-related will not be supported prior to .NET Standard 2.1, and .NET Framework 3.0 and older are considered too old to be necessarily supported in this repository.
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.