4.2 KiB
4.2 KiB
GitHub Copilot Instructions — Fixiy
Language and Style
- C# 12+ with
<Nullable>enable</Nullable>and<ImplicitUsings>enable</ImplicitUsings>throughout. Never disable these per-file without strong justification. - Use file-scoped namespaces (
namespace Fixiy.Shared.Services;) not block-scoped. - Prefer
recordtypes for immutable DTOs. - Use
async/awaitconsistently — never.Resultor.Wait()on Tasks. - Remove unused
usingdirectives.
Blazor Component Conventions
- All shared components live in
Fixiy.Shared/Components/. Do not create components inFixiy.MauiorFixiy.Web. - Pages go in
Fixiy.Shared/Components/Pages/, layout inLayout/, reusable elements inSingleElements/. - Scoped CSS goes in a matching
.razor.cssfile alongside the component. - Inject services via
@injectin.razorfiles — Blazor components do not support constructor injection. - Prefer
[Parameter]for component inputs; avoid cascading parameters unless genuinely needed across deep trees.
Render Mode Rules
- Always use
InteractiveRenderSettings.*properties (@InteractiveServer,@InteractiveAuto,@InteractiveWebAssembly) in shared components — never hard-codedRenderMode.*constants. Fixiy.Maui/MauiProgram.cscallsConfigureBlazorHybridRenderModes()which sets all three properties tonull. This is intentional — MAUI Blazor Hybrid runs components statically.- Do not work around the null render modes in shared code. Components that need interactivity must tolerate
nullrender mode in MAUI context.
IFormFactor Platform Abstraction
- Platform-specific device info must be accessed via
IFormFactorinjection (Fixiy.Shared/Interfaces/IFormFactor.cs). - Never call
DeviceInfo,Connectivity,FileSystem, or anyMicrosoft.Maui.*API fromFixiy.Shared. - When adding new platform capabilities: define interface in
Fixiy.Shared/Interfaces/→ implement in bothFixiy.Maui/Services/andFixiy.Web/Services/→ register in both DI roots.
IntegryApiClient Registration
- Register with the same
appTokenanduseLoginAzienda: truein both hosts. - MAUI:
.UseIntegry(appToken, useLoginAzienda: true)on theMauiAppBuilderchain. - Web:
builder.Services.UseIntegry(appToken, useLoginAzienda: true)inProgram.cs. - One registration per DI root — do not call it twice.
Service Registration Lifetimes
Fixiy.Mauiregisters platform services asSingleton— the MAUI app has a single long-lived process.Fixiy.Webregisters platform services asScoped— ASP.NET Core server-side per-request scope.- Interfaces must not assume a specific lifetime; implementations may.
Maintenance Matrix
| Change | Cascades to |
|---|---|
Add/modify Fixiy.Shared/Interfaces/*.cs |
Both Fixiy.Maui/Services/ and Fixiy.Web/Services/ implementations + DI registration in both hosts |
Modify InteractiveRenderSettings.cs |
MauiProgram.ConfigureBlazorHybridRenderModes() — must null every new property |
| Add a new shared page | Fixiy.Shared/Components/Pages/ → nav link in NavMenu.razor if user-accessible |
| Add a NuGet package | Target .csproj file; check private NuGet feed has it |
| Change IntegryApiClient version | All three .csproj files (Fixiy.Maui, Fixiy.Shared, Fixiy.Web) |
Modify _Imports.razor |
Verify no MAUI-only or web-only namespaces are introduced |
| Update app token | Fixiy.Maui/MauiProgram.cs AppToken const + Fixiy.Web/Program.cs appToken const |
Test Conventions
- No test projects are currently configured. When adding tests, use xUnit with bUnit for Razor component testing.
- Test projects should reference
Fixiy.Sharedand provide mock implementations ofIFormFactor. - Use
MoqorNSubstitutefor mocking; do not create manual stubs unless the interface is trivial.
Code Style Notes
- Omit the
privatemodifier on fields — it is the default in C#. - Constants:
PascalCasefor class-levelconst, no Hungarian notation. - One type per file; file name matches type name.
- Keep
@codeblocks in.razorfiles focused — extract complex logic to a*.razor.cscode-behind or a separate service class.