FluentPermissions 1.0.0-preview.1.2602211042
This is a prerelease version of FluentPermissions.
dotnet add package FluentPermissions --version 1.0.0-preview.1.2602211042
NuGet\Install-Package FluentPermissions -Version 1.0.0-preview.1.2602211042
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="FluentPermissions" Version="1.0.0-preview.1.2602211042" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FluentPermissions" Version="1.0.0-preview.1.2602211042" />
<PackageReference Include="FluentPermissions" />
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 FluentPermissions --version 1.0.0-preview.1.2602211042
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FluentPermissions, 1.0.0-preview.1.2602211042"
#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 FluentPermissions@1.0.0-preview.1.2602211042
#: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=FluentPermissions&version=1.0.0-preview.1.2602211042&prerelease
#tool nuget:?package=FluentPermissions&version=1.0.0-preview.1.2602211042&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
FluentPermissions
FluentPermissions is a Roslyn incremental source generator for permission modeling in .NET. You define permissions with a fluent DSL, and get compile-time generated constants + read-only query APIs.
What It Generates
- Namespace:
$(AssemblyName).Security - Entry type:
public static partial class AppPermissions - Flat permission code constants
- Read-only descriptors:
AppPermissions.All - Common lookup/query members:
AppPermissions.ByCodeAppPermissions.AllCodes,AppPermissions.GetAllCodes()AppPermissions.Contains(code)AppPermissions.TryGet(code, out descriptor)AppPermissions.GetByCode(code)AppPermissions.GetChildren(parentCode)AppPermissions.GetLeaves()
Repository Layout
FluentPermissions.Core(netstandard2.0): contracts + fluent builder DSLFluentPermissions(netstandard2.0): source generatorFluentPermissions.Sample(net9.0): usage sampleFluentPermissions.Tests(net9.0): generator tests
Quick Start
- Add references
- Reference
FluentPermissions.Corein your app project - Add
FluentPermissionsas source generator (analyzer/NuGet)
- Define a single options type
using FluentPermissions.Core.Abstractions;
public sealed class SampleOptions : PermissionOptionsBase
{
public int DisplayOrder { get; set; }
public string? Icon { get; set; }
public bool IsHighRisk { get; set; }
}
- Implement registrar
using FluentPermissions.Core.Abstractions;
using FluentPermissions.Core.Builder;
public sealed class AppPermissionDefinition : IPermissionRegistrar<SampleOptions>
{
public void Register(PermissionBuilder<SampleOptions> builder)
{
builder
.DefineGroup("System", "System", "Core system settings", system =>
{
system.WithOptions(o =>
{
o.DisplayOrder = 10;
o.Icon = "fa-gear";
});
system.DefineGroup("Users", "User management", users =>
{
users.AddPermission("Create", "Create user");
users.AddPermission("Delete", "Delete user", "High risk", o => o.IsHighRisk = true);
});
})
.DefineGroup("Reports", reports =>
{
reports.AddPermission("View", "View reports");
reports.AddPermission("Export", "Export reports");
});
}
}
- Consume generated API
using MyApp.Security;
var code = AppPermissions.System_Users_Create; // APP:System:Users:Create
if (AppPermissions.TryGet(code, out var descriptor))
{
Console.WriteLine(descriptor!.DisplayOrName);
Console.WriteLine(descriptor.Parent);
}
foreach (var c in AppPermissions.GetAllCodes())
Console.WriteLine(c);
Global Generation Option (Attribute)
Use PermissionGenerationOptionsAttribute to control whether groups themselves are emitted as permission items.
- Default:
true - If
false:- group descriptors are not emitted into
AppPermissions.All - group constants are not emitted
- only leaf permission constants/descriptors remain
- group descriptors are not emitted into
You can place it on assembly or registrar class.
using FluentPermissions.Core.Abstractions;
[assembly: PermissionGenerationOptions(false)]
// or: [PermissionGenerationOptions(false)] on registrar class
Generated Model
PermissionDescriptor:
Code: full code (e.g.APP:System:Users:Create)Name: logical name (e.g.Create)DisplayName: optional display nameParent: parent code (e.g.APP:System:Users)IsLeaf: whether this is a leaf permissionIsGroup => !IsLeafDisplayOrName => DisplayName ?? Name
Notes
- Analyzer diagnostics include consistency checks for generic options across registrars (
FP0002).
License
MIT
There are no supported framework assets in this package.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- FluentPermissions.Core (>= 1.0.0-preview.1.2602211042)
- Microsoft.CodeAnalysis.CSharp (>= 4.3.0)
- Microsoft.CodeAnalysis.CSharp.Workspaces (>= 4.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-preview.1.2602211042 | 148 | 2/21/2026 |
| 1.0.0-preview.1.2602191410 | 73 | 2/19/2026 |
| 1.0.0-preview.1.2509210917 | 160 | 9/21/2025 |
| 1.0.0-preview.1.2509210705 | 141 | 9/21/2025 |
| 1.0.0-preview.1.2509210644 | 147 | 9/21/2025 |
| 1.0.0-beta.3 | 145 | 9/21/2025 |
| 1.0.0-beta.2 | 177 | 9/20/2025 |
| 1.0.0-beta.1 | 174 | 9/20/2025 |