Skip to content

C# code bits of internal implementations that are shared in projects. Meant to be used alongside Absence.Fody.

License

Notifications You must be signed in to change notification settings

Emik03/Emik.Morsels

Repository files navigation

Emik.Morsels

License



About

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.

Usage

  1. Download the .NET 9 SDK.
  2. Download/clone the repository: git clone https://github.com/Emik03/Emik.Morsels.git
  3. Copy-paste Directory.Build.local.props.template and name the new duplicate Directory.Build.local.props.
  4. Modify the PropertyGroup of Directory.Build.local.props, which contains absolute paths that are system-dependent.
  5. 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.

Family

The following block contains officially maintained projects that implement Emik.Morsels:

Absence.Fody Divorce.Fody Emik.Analyzers.Matches Emik.Kebnekaise.Gramophones Emik.Kebnekaise.Pistons Emik.Morsels.ProjectTemplates Emik.Numerics.Fractions Emik.Results Emik.Rhainterop Emik.Rubbish Emik.SourceGenerators.Choices Emik.SourceGenerators.Implicit Emik.SourceGenerators.Tattoo Emik.SourceGenerators.TheSquareHole Emik.Unions ScreenShakeService wawa

Tree Shaking

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.

Supported Frameworks

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.

Modified Standard Library

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.

Contribute

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.

License

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.

Releases

No releases published

Packages

No packages published

Languages