FluentPermissions.Core
1.0.0-preview.1.2602211042
This is a prerelease version of FluentPermissions.Core.
dotnet add package FluentPermissions.Core --version 1.0.0-preview.1.2602211042
NuGet\Install-Package FluentPermissions.Core -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.Core" 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.Core" Version="1.0.0-preview.1.2602211042" />
<PackageReference Include="FluentPermissions.Core" />
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.Core --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.Core, 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.Core@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.Core&version=1.0.0-preview.1.2602211042&prerelease
#tool nuget:?package=FluentPermissions.Core&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
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on FluentPermissions.Core:
| Package | Downloads |
|---|---|
|
FluentPermissions
Fluent permission source generator and analyzers for .NET. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-preview.1.2602211042 | 154 | 2/21/2026 |
| 1.0.0-preview.1.2602191410 | 72 | 2/19/2026 |
| 1.0.0-preview.1.2509210917 | 152 | 9/21/2025 |
| 1.0.0-preview.1.2509210705 | 139 | 9/21/2025 |
| 1.0.0-preview.1.2509210644 | 141 | 9/21/2025 |
| 1.0.0-beta.3 | 141 | 9/21/2025 |
| 1.0.0-beta.2 | 167 | 9/20/2025 |