Provides guidance on Orchard Core source generators and build-time analyzers, including GenerateArguments, GenerateShape, OCSG001/OCSG002 analyzers, and migration from anonymous to named types for performance optimization.
Ships in orchardcore. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are an Orchard Core expert. Generate code using source generators, the [GenerateArguments] attribute, anonymous type interceptors, and named argument types for shapes and display management.
[GenerateArguments] on partial classes to generate optimized INamedEnumerable<object> implementations at compile time.PropertyBasedNamedEnumerable with zero-reflection property access via switch expressions.[GenerateArguments] must be partial and have at least one public instance property with a getter.Arguments.From() are automatically optimized by interceptors.Arguments.From() falls back to cached reflection (acceptable for infrequent usage).[GenerateArguments] for production code over anonymous types.OrchardCore.SourceGenerators ships as an analyzer with the Orchard Core packages; no extra reference is needed in modules built on OrchardCore.Module.Targets.Initialize<TModel>() or proxy-based CreateAsync<TModel>() must not be sealed (OCSG001), unless they implement IShape.[Feature("...")] on a type must name a feature declared by the same module (OCSG002); use [RequireFeatures("...")] for other modules' features.sealed modifier where applicable.using OrchardCore.DisplayManagement;
[GenerateArguments]
public sealed partial class MyShapeArguments
{
public string Title { get; set; }
public int Count { get; set; }
public bool IsActive { get; set; }
}
// Usage - direct property access, no reflection
var args = new MyShapeArguments
{
Title = "Hello",
Count = 42,
IsActive = true,
};
var shape = await shapeFactory.CreateAsync("MyShape", args);
The source generator produces an optimized implementation extending PropertyBasedNamedEnumerable:
// Your code:
[GenerateArguments]
public sealed partial class MyData
{
public string Name { get; set; }
public int Value { get; set; }
}
// Auto-generated at compile time:
public sealed partial class MyData : PropertyBasedNamedEnumerable
{
private static readonly string[] s_propertyNames = ["Name", "Value"];
protected override int PropertyCount => 2;
protected override IReadOnlyList<string> PropertyNames => s_propertyNames;
protected override object? GetPropertyValue(int index) => index switch
{
0 => this.Name,
1 => this.Value,
_ => throw new ArgumentOutOfRangeException(nameof(index))
};
}
[GenerateArguments]
public partial class PagerSlim
{
public int PageSize { get; set; }
public string Before { get; set; }
public string After { get; set; }
}
[GenerateArguments]
internal sealed partial class ContentZoneArguments
{
public string Identifier { get; set; }
}
[GenerateArguments]
internal sealed partial class NavigationArguments
{
public string MenuName { get; set; }
public string RouteUrl { get; set; }
}
For .NET 9+ projects, anonymous types are automatically optimized using C# interceptors with no code changes:
// Automatically optimized at compile time
var shape = await factory.CreateAsync("MyShape", new
{
Title = "Hello",
Count = 42,
});
Requirements:
Orchard Core 4.0 projects target net11.0, which meets both requirements.
How it works: The interceptor detects Arguments.From(anonymousType) calls and generates optimized code using type inference to cast to the actual anonymous type, eliminating reflection and dynamic overhead.
On older .NET versions, Arguments.From() uses cached reflection:
// Works on any .NET version - uses reflection + caching
var args = Arguments.From(new { Title = "Test", Count = 5 });
// Before (anonymous type):
var shape = await factory.CreateAsync("MyShape", new
{
Title = "Hello",
Count = 5,
});
// After (recommended named type):
[GenerateArguments]
public sealed partial class MyShapeArguments
{
public string Title { get; set; }
public int Count { get; set; }
}
var args = new MyShapeArguments { Title = "Hello", Count = 5 };
var shape = await factory.CreateAsync("MyShape", args);
public sealed partial class OuterClass
{
[GenerateArguments]
public sealed partial class InnerArguments
{
public string Value { get; set; }
}
}
[GenerateArguments]
public sealed partial record MyRecordArgs(string Title, int Count);
Production code with reusable types?
├─ Yes → Use [GenerateArguments] ✅ RECOMMENDED
└─ No
└─ Using .NET 9+ with anonymous types?
├─ Yes → Interceptors (automatic) ✅
└─ No → Reflection with caching (acceptable for rare usage)
| Rule | Severity | Reported when | Fix |
|---|---|---|---|
OCSG001 | Warning | A sealed type that does not implement IShape is passed to a proxy-based shape API such as Initialize<TModel>() or CreateAsync<TModel>() | Remove sealed, implement IShape, or use View(), Copy() or Dynamic() |
OCSG002 (4.0) | Warning | OrchardCore.Modules.FeatureAttribute targets a feature ID not declared by the current module assembly | Use a local feature ID, or [RequireFeatures(...)] for another module's feature |
// warning OCSG001: Type 'DebugSettingsViewModel' is sealed and does not implement IShape ...
public sealed class DebugSettingsViewModel
{
public bool WriteShapeDebugInformation { get; set; }
}
// Fix: view models stay unsealed.
public class DebugSettingsViewModel
{
public bool WriteShapeDebugInformation { get; set; }
}
Orchard Core resolves [Feature] targets only against the features of the same assembly. A cross-module ID is silently ignored and the type falls back to the module's default feature mapping, so the startup runs when you did not expect it.
// warning OCSG002: Feature 'OrchardCore.Liquid' is not defined by the current module 'MyModule', so OrchardCore will ignore this target.
[Feature("OrchardCore.Liquid")]
public sealed class LiquidStartup : StartupBase { }
// Fix: depend on the other module's feature.
[RequireFeatures("OrchardCore.Liquid")]
public sealed class LiquidStartup : StartupBase { }
[GenerateShape])Proxy-based shapes (Initialize<TModel>()) normally subclass the model at runtime with Castle DynamicProxy. The shape factory generator intercepts these calls at compile time for non-abstract classes with an accessible parameterless constructor and generates the derived shape type instead, so no runtime proxy is built. Sealed models still cannot be derived from (OCSG001).
To make the model itself the shape, mark a partial class with [GenerateShape]; the generator implements IShape and IPositioned on it:
using OrchardCore.DisplayManagement;
[GenerateShape]
public partial class WeatherWidgetViewModel
{
public string City { get; set; }
public double Temperature { get; set; }
}
Generated shape types are named GeneratedShape_<hash>, where the hash covers the identity of the consuming assembly and the model's full name. Each assembly that calls Initialize<TModel>() or CreateAsync<TModel>() on a model of a shared library gets its own public wrapper type, so two assemblies generating wrappers for the same model no longer collide (CS0436). Never reference a GeneratedShape_* type by name: it changes with the assembly.
This generator is newer than the published docs; inspect the generated files under obj/<Configuration>/<TargetFramework>/generated/OrchardCore.SourceGenerators/ when troubleshooting.
"Type must be partial" — Add the partial keyword:
// Correct
[GenerateArguments]
public sealed partial class MyData { }
// Wrong - will not compile
[GenerateArguments]
public sealed class MyData { }
Generated code not found:
obj/<Configuration>/<TargetFramework>/generated/ for generated filesDo not manually cast to INamedEnumerable:
// Correct - pass arguments directly
var args = new MyShapeArguments { Title = "Test" };
var shape = await factory.CreateAsync("MyShape", args);
// Wrong - unnecessary manual cast
var enumerable = (INamedEnumerable<object>)args;
[GenerateArguments] for all production shape arguments.UserProfileShapeArgs over Args).What SKILL.md sets; muted values are Claude Code's defaults
/orchardcore:orchardcore-source-generatorsfrom orchardcore
npx claudepluginhub crestapps/crestapps.agentskills --plugin orchardcore140 skills in this plugin
/orchardcore-adminGuidance for the Orchard Core admin panel, including admin controllers and routes, admin menu registration with AdminNavigationProvider, ocat editor forms grouped in cards, admin pages rendering Model.Editor, the UI text casing standard, TheAdmin layout and menu colors, admin branding, the Navbar shape, the Ctrl+K quick navigation palette and QuickNavigationSource, AdminSettings such as MenuBehavior, ShowBreadcrumb, DisplayQuickNavigation, DisplayTitlesInTopbar and ActionsLayout, the AdminDashboard shape, settings pages, and admin filters and zones. Use this skill when requests mention the Orchard Core admin panel, TheAdmin, admin controllers, admin menu registration, an icon on an admin menu item, the AdminSettings recipe step, quick navigation, navigation menu behavior, the admin URL prefix, UI text casing. Strong matches include OrchardCore.Admin, AdminSettings, AdminPermissions, AdminOptions, AdminAttribute, SiteDisplayDriver, IDisplayManager./orchardcore-admin-dashboardSkill for creating admin dashboard widgets in Orchard Core. Covers the DashboardWidget stereotype, DashboardPart position and sizing, the built-in HtmlDashboardWidget, ContentsMetadata and ContentsTags widget types, custom widget content types via recipe or migration, arranging widgets in Manage Dashboard mode, widget template customization, provisioning widgets with recipes, dashboard permissions, the DashboardBreadcrumbProvider Dashboard ancestor, and the AdminDashboardContent shape used when the feature is disabled. Use this skill when requests mention Orchard Core Admin Dashboard, Create and Configure Dashboard Widgets, Enabling Admin Dashboard, Widget Configuration Properties, dashboard widget recipes, Dashboard breadcrumb, or related implementation, setup, or troubleshooting work. Strong matches include OrchardCore.AdminDashboard, DashboardPart, DashboardBreadcrumbProvider, AccessAdminDashboard, ManageAdminDashboard.Other plugins' skills for the same job