Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emik03/emik.morsels
C# code bits of internal implementations that are shared in projects. Meant to be used alongside Absence.Fody.
https://github.com/emik03/emik.morsels
algorithms bridge config csharp fsharp helper metaproject morsels performance polyfill props superproject symlink targets unmanaged-memory utility
Last synced: 3 months ago
JSON representation
C# code bits of internal implementations that are shared in projects. Meant to be used alongside Absence.Fody.
- Host: GitHub
- URL: https://github.com/emik03/emik.morsels
- Owner: Emik03
- License: mpl-2.0
- Created: 2022-11-22T07:53:07.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-23T21:28:31.000Z (4 months ago)
- Last Synced: 2024-10-24T08:47:15.477Z (4 months ago)
- Topics: algorithms, bridge, config, csharp, fsharp, helper, metaproject, morsels, performance, polyfill, props, superproject, symlink, targets, unmanaged-memory, utility
- Language: C#
- Homepage:
- Size: 6.88 MB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Emik.Morsels
[](https://github.com/Emik03/Emik.Morsels/blob/main/LICENSE)
---
- [About](#about)
- [Usage](#usage)
- [Family](#family)
- [Tree Shaking](#tree-shaking)
- [Supported Frameworks](#supported-frameworks)
- [Modified Standard Library](#modified-standard-library)
- [Contribute](#contribute)
- [License](#license)---
## About
Inspired by [Code](https://github.com/shaynevanasperen/Code/); This is a project that contains utility code that don't belong together in a monolithic library. However, as opposed to [Code](https://github.com/shaynevanasperen/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](https://dotnet.microsoft.com/en-us/download/dotnet/9.0).
2. Download/clone the repository: `git clone https://github.com/Emik03/Emik.Morsels.git`
3. Copy-paste [Directory.Build.local.props.template](https://raw.githubusercontent.com/Emik03/Emik.Morsels/main/Content/Properties/Directory.Build.local.props.template) and name the new duplicate `Directory.Build.local.props`.
4. Modify the [PropertyGroup](https://learn.microsoft.com/en-us/visualstudio/msbuild/propertygroup-element-msbuild?view=vs-2022) of `Directory.Build.local.props`, which contains absolute paths that are system-dependent.
5. Execute [this command on Windows](https://github.com/Emik03/Emik.Morsels/blob/main/Shell/symlink.bat) or [this command on Mac/Linux](https://github.com/Emik03/Emik.Morsels/blob/main/Shell/symlink.sh) with each [Emik.Morsels](https://github.com/Emik03/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](https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2022#search-scope) as well.## Family
The following block contains officially maintained projects that implement [Emik.Morsels](https://github.com/Emik03/Emik.Morsels):
[](https://github.com/Emik03/Absence.Fody)
[](https://github.com/Emik03/Divorce.Fody)
[](https://github.com/Emik03/Emik.Analyzers.Matches)
[](https://github.com/Emik03/Emik.Kebnekaise.Gramophones)
[](https://github.com/Emik03/Emik.Kebnekaise.Pistons)
[](https://github.com/Emik03/Emik.Morsels.ProjectTemplates)
[](https://github.com/Emik03/Emik.Numerics.Fractions)
[](https://github.com/Emik03/Emik.Results)
[](https://github.com/Emik03/Emik.Rhainterop)
[](https://github.com/Emik03/Emik.Rubbish)
[](https://github.com/Emik03/Emik.SourceGenerators.Choices)
[](https://github.com/Emik03/Emik.SourceGenerators.Implicit)
[](https://github.com/Emik03/Emik.SourceGenerators.Tattoo)
[](https://github.com/Emik03/Emik.SourceGenerators.TheSquareHole)
[](https://github.com/Emik03/Emik.Unions)
[](https://github.com/Emik03/ScreenShakeService)
[](https://github.com/Emik03/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](https://github.com/Emik03/Absence.Fody/) which automatically looks for unused types that aren't explicitly marked as either [CompilerGeneratedAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.compilergeneratedattribute?view=net-7.0) or [ImplicitlyUsedAttribute](https://www.jetbrains.com/help/resharper/Reference__Code_Annotation_Attributes.html#UsedImplicitlyAttribute). As a result, any unused types outside of [Emik.Morsels](https://github.com/Emik03/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.0Different 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`](https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/static-abstract-interface-methods) 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](https://github.com/Emik03/Emik.Net20Records).
This method is attributed with [`InlineAttribute`](https://github.com/oleg-st/InlineMethod.Fody) 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](https://gist.github.com/Emik03/d88efe49a874b7d5f45e4bfb96fa541f).
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](https://www.mozilla.org/en-US/MPL/2.0/).
You may copy individual or multiple source files, granted that you keep the copyright license, and disclose the source back to this repository.