Muslim.Helpers 10.0.1

dotnet add package Muslim.Helpers --version 10.0.1
                    
NuGet\Install-Package Muslim.Helpers -Version 10.0.1
                    
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="Muslim.Helpers" Version="10.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Muslim.Helpers" Version="10.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Muslim.Helpers" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Muslim.Helpers --version 10.0.1
                    
#r "nuget: Muslim.Helpers, 10.0.1"
                    
#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.
#:package Muslim.Helpers@10.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Muslim.Helpers&version=10.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Muslim.Helpers&version=10.0.1
                    
Install as a Cake Tool

Muslim.Helpers

Three small helpers for .NET 10 applications: a contract for the signed-in user, a Base64 file decoder, and an EF Core converter that stores a list of strings in one column.

dotnet add package Muslim.Helpers
Type Namespace What it does
ICurrentUser Muslim.Helpers The user of the current request
Base64Data Muslim.Core.Common Decodes data:image/png;base64,...
StringListConverter, StringListComparer Muslim.Core.EfConverters Stores a List<string> as a,b,c

Current user

The package defines the contract. Your application implements it once:

using System.Security.Claims;
using Muslim.Helpers;

public class CurrentUser(IHttpContextAccessor accessor) : ICurrentUser
{
    private ClaimsPrincipal? User => accessor.HttpContext?.User;

    public int UserId => int.TryParse(User?.FindFirst("Id")?.Value, out var id) ? id : 0;
    public string UserName => User?.Identity?.Name ?? "";
    public string Email => User?.FindFirst(ClaimTypes.Email)?.Value ?? "";
    public string Phone => User?.FindFirst(ClaimTypes.MobilePhone)?.Value ?? "";
    public string UserType => User?.FindFirst("UserType")?.Value ?? "";
    public string DeviceToken => User?.FindFirst("DeviceToken")?.Value ?? "";
    public string RemoteIpAddress => accessor.HttpContext?.Connection.RemoteIpAddress?.ToString() ?? "";
    public IEnumerable<string> Permissions => User?.FindAll("Permission").Select(c => c.Value) ?? [];
    public bool IsUserHasPermission(string permission) => Permissions.Contains(permission);
}

Register it:

builder.Services.AddHttpContextAccessor();
builder.Services.AddAutoInjection(typeof(CurrentUser).Assembly);

Then inject ICurrentUser anywhere:

public class OrderService(ICurrentUser currentUser)
{
    public bool CanApprove => currentUser.IsUserHasPermission("orders.approve");
}
  • ICurrentUser is marked for Muslim.Inject, so AddAutoInjection registers your class as scoped. No AddScoped line is needed.
  • Return 0 from UserId when no one is signed in.

Base64 files

using Muslim.Core.Common;

var file = new Base64Data(request.Image);   // "data:image/png;base64,iVBORw0KGgo..."

byte[] bytes = file.Bytes;                  // the decoded file
string type  = file.Extension;              // "png"
  • Extension is the type exactly as sent: png, jpeg, svg+xml, plain. It is not checked. Compare it with a list of allowed types before you use it in a file name.
  • Bad input (empty, no type, no comma, invalid Base64) throws ArgumentException with the message invalid base64 string. The original error is in InnerException.
  • The whole file is decoded into memory. Limit the request size.

A list of strings in one column

using Muslim.Core.EfConverters;

public class Article
{
    public int Id { get; set; }
    public List<string> Tags { get; set; } = [];
}

modelBuilder.Entity<Article>().Property(x => x.Tags).HasStringListConversion();

["news", "sport"] is saved as news,sport and read back as a list.

For every List<string> in the model at once:

protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
    => configurationBuilder.Properties<List<string>>()
        .HaveConversion<StringListConverter, StringListComparer>();
  • Always use the comparer with the converter. HasStringListConversion does both. With the converter alone, EF Core does not notice Tags.Add(...) on a loaded entity and saves nothing.
  • Items must not contain commas. ["a,b"] reads back as ["a", "b"].
  • An empty list is saved as an empty string and reads back as an empty list.
  • Queries that look inside the list, such as Tags.Contains("news"), cannot run in SQL.
Package Use it for
Muslim.Inject Automatic dependency registration

Coding-agent guidance

When you build a project that uses this package, a short guide for AI coding agents is copied to .agents/skills/muslim-helpers/ at the root of your repository. Agents that read skills from .agents/skills, such as Codex and GitHub Copilot in VS Code, use it to write correct code against this package. Your own files and other skills are never touched, and nothing is deleted automatically.

To turn it off, add this to your project or Directory.Build.props:

<PropertyGroup>
  <MuslimHelpersGenerateSkill>false</MuslimHelpersGenerateSkill>
</PropertyGroup>

License

See LICENSE.txt.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Muslim.Helpers:

Package Downloads
Muslim.GenericRepository

EF Core repository for entities with audit columns: reads, writes, soft delete, bulk operations and raw SQL, with CreatedBy/UpdateBy/DeletedBy and UTC timestamps written automatically. Implements Muslim.GenericRepository.Interface.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.1 114 10/15/2026
8.0.0 175 9/23/2026
1.0.1 149 8/10/2026
1.0.0 409 10/5/2024

StringListConverter now reads an empty column back as an empty list; new StringListComparer and HasStringListConversion make EF Core save in-place list changes. Base64Data keeps the decoding error as InnerException and parses without splitting the whole string. Ships version-matched agent guidance and generates .agents/skills/muslim-helpers during normal consuming builds; preserves user files and supports MuslimHelpersGenerateSkill=false. See CHANGELOG.md and README.md.