Skip to content

Add .NET Core Rules for ASP.NET Identity, Razor Pages, and xUnit Testing #33

@bartoszclapinski

Description

@bartoszclapinski

Hi there! 👋

I'd like to contribute new rules for the 10xRules.ai collection that would be valuable for .NET developers working with ASP.NET Core.

New Rules to Add:

  1. ASP.NET Core Identity - Guidelines for implementing authentication and authorization
  2. Razor Pages - Best practices for ASP.NET Core Razor Pages development
  3. xUnit Testing - Rules for effective testing with xUnit in .NET projects

These rules align well with the existing .NET rules and would add value for developers building document management systems and similar applications with ASP.NET Core.

Rule Contents:

1. ASP.NET Core Identity

## BACKEND

### Guidelines for DOTNET

#### IDENTITY

- Use ASP.NET Core Identity with Entity Framework Core for user management
- Implement custom user and role classes extending IdentityUser and IdentityRole
- Apply policy-based authorization for complex permission scenarios
- Use UserManager and RoleManager for user and role operations
- Implement secure password policies and account lockout settings
- Use claims-based authentication for fine-grained access control

2. Razor Pages

## BACKEND

### Guidelines for DOTNET

#### RAZOR_PAGES

- Organize Razor Pages in feature folders to maintain clean architecture
- Use PageModel properties with data annotations for form validation
- Implement partial views for reusable UI components across multiple pages
- Use route constraints in @page directives to handle different URL patterns
- Apply proper authorization using the [Authorize] attribute or policy-based authorization
- Implement handler methods (OnGet, OnPost) with proper return types (IActionResult)

3. xUnit Testing

## TESTING

### Guidelines for UNIT_TESTING

#### XUNIT

- Use [Fact] for simple tests and [Theory] with [InlineData] for parameterized tests
- Organize test classes to mirror the structure of the application code
- Use FluentAssertions for more readable assertions when appropriate
- Implement test fixtures with IClassFixture for shared context between tests
- Use Moq for mocking dependencies in unit tests
- Apply AAA (Arrange-Act-Assert) pattern for clear test structure

These rules were developed as part of my work with the 10xDevs course.

Note: As I'm still learning and not yet a professional developer, it would be great to have these guidelines reviewed by more experienced developers. If you have suggestions for improvements or spot any issues, please feel free to share your feedback!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions