Skip to content

Commit a6216b7

Browse files
committed
Update documentation, workflows, and best practices
- Added a new funding platform in `FUNDING.yml`. - Overhauled `copilot-instructions.md` with a role description. - Introduced `.NET architect` and `Code Reviewer` guidelines. - Added best practices for .NET Core in `solution_architect.mdc`. - Updated GitHub Actions to include `develop` branch triggers. - Improved `nuget-publish.yml` syntax for environment variables. - Upgraded `Roslynator.Analyzers` to version 4.14.1. - Removed unnecessary `genocs.cli.csproj.user` file. - Added "Documentation Writer Mode" for API and code documentation.
1 parent d441251 commit a6216b7

File tree

10 files changed

+155
-122
lines changed

10 files changed

+155
-122
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
description: This rule provides comprehensive best practices for developing dotnet applications, covering code organization, security, performance, testing, and common pitfalls. It aims to improve code quality, security posture, and overall efficiency when working with the .NET Core framework.
3+
globs: *.tf,*.bicep,*.json,*.yml,*.yaml,*.cs,*.csproj,*.sln
4+
alwaysApply: false
5+
---
6+
7+
# .NET Core Library Best Practices and Coding Standards
8+
9+
This document outlines the recommended best practices for developing applications and infrastructure using Microsoft .NET Core, Azure DevOps and Azure services. It covers various aspects including solution setup, code organization, security, and tooling to ensure robust, scalable, and secure solutions.
10+
11+
## 1. Code Organization and Structure
12+
13+
A well-organized codebase is crucial for maintainability, scalability, and collaboration. The following guidelines provide a structured approach to organizing your .NET projects.
14+
15+
### Directory Structure Best Practices
16+
17+
Adopt a modular and logical directory structure based on the application's architecture and components.
18+
19+
* **`devops/`**: Contains the root folder for DevOps pipelines for your application.
20+
* **`azure/`**: Contains the source code of Azure DevOps pipelines for your application.
21+
* **`infrastructure/`**: Contains the source code of IaC and platform setup scripts for your application.
22+
* **`bicep/`**: Contains the source code of Bicep templates for your application.
23+
* **`terraform/`**: Contains the source code of Terraform templates for your application.
24+
* **`scripts/`**: Automation scripts for deployment, build processes, etc.
25+
* **`src/`**: Contains the source code of your application.
26+
27+
28+
Example:
29+
30+
root-project/
31+
├── .cursor/
32+
│ └── rules/
33+
├── .git/
34+
├── .github/
35+
│ ├── chatmode
36+
│ ├── instructions
37+
│ └── workflows/
38+
├── devops/
39+
│ └── azure/
40+
├── infrastructure/
41+
│ ├── bicep/
42+
│ └── terraform/
43+
├── scripts/
44+
├── src/
45+
├── .editorconfig
46+
├── .gitattributes
47+
├── .gitignore
48+
├── CHANGELOG.md
49+
├── CODE_OF_CONDUCT.md
50+
├── Directory.Build.props
51+
├── Directory.Build.targets
52+
├── dotnet.ruleset
53+
├── global.json
54+
├── stylecop.json
55+
├── nuget.config
56+
├── project.sln
57+
└── README.md
58+
59+
60+
### File Naming Conventions
61+
62+
Maintain consistency in file naming to improve readability and searchability.
63+
64+
* Use descriptive names that reflect the file's purpose.
65+
* Use a consistent case (e.g., camelCase or kebab-case).
66+
* Use appropriate file extensions (e.g., `.cs`, `.csproj`, `.tf`, `.bicep`).
67+
* For CSharp components, use `ClassName.cs` or `ComponentName.SubComponent.cs`.
68+
69+
Example:
70+
71+
* `user-service.js` (for a user service module)
72+
* `UserProfile.jsx` (for a user profile component)
73+
* `storage-account.tf` (for a Terraform file defining a storage account)
74+
75+
### Module Organization
76+
77+
Divide the application into independent and reusable modules based on functionality.
78+
79+
* Each module should have a clear responsibility and a well-defined interface.
80+
* Minimize dependencies between modules to promote loose coupling.
81+
* Consider using a module bundler (e.g., Webpack, Parcel) to manage dependencies and optimize the build process.
82+
83+
Example:
84+
85+
A `user-management` module could contain components and services related to user authentication, authorization, and profile management.
86+
87+
88+
By following these best practices, you can build robust, scalable, secure, and maintainable .NET applications.

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# These are supported funding model platforms
22
open_collective: genocs
3-
custom: ['https://www.buymeacoffee.com/genocs']
3+
custom: ["https://www.buymeacoffee.com/genocs"]
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: code_reviewer
3+
target: vscode
4+
description: Review code for quality and adherence to best practices.
5+
argument-hint: The user will provide code snippets or files to review.
6+
tools: ["search/codebase", "usages", "vscodeAPI", "problems", "fetch", "githubRepo", "search"]
7+
---
8+
9+
# Code Reviewer Mode
10+
11+
You are an experienced senior developer conducting a thorough code review. Your role is to review the code for quality, best practices, and adherence to [project standards](../copilot-instructions.md) without making direct code changes.
12+
13+
## Analysis Focus
14+
15+
- Analyze code quality, structure, and best practices
16+
- Identify potential bugs, security issues, or performance problems
17+
- Evaluate accessibility and user experience considerations
18+
- Assess maintainability and readability
19+
20+
## Communication Style
21+
22+
- Provide constructive, specific feedback with clear explanations
23+
- Highlight both strengths and areas for improvement
24+
- Ask clarifying questions about design decisions when appropriate
25+
- Suggest alternative approaches when relevant
26+
27+
## Important Guidelines
28+
29+
- DO NOT write or suggest specific code changes directly
30+
- Focus on explaining what should be changed and why
31+
- Provide reasoning behind your recommendations
32+
- Be encouraging while maintaining high standards
33+
34+
When reviewing code, structure your feedback with clear headings and specific examples from the code being reviewed.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: documentation_writer
3+
description: Document code and its functionality.
4+
tools: [search]
5+
---
6+
7+
# Documentation Writer Mode
8+
You are a Documentation Writer. Your task is to create clear, concise, and comprehensive documentation for codebases, APIs, libraries, and software projects. You should focus on explaining complex technical concepts in an accessible manner, ensuring that the documentation is useful for both novice and experienced developers.
9+
10+
## Documentation Focus
11+
- Write clear and concise explanations of code functionality
12+
- Include usage examples and code snippets where applicable
13+
- Document any dependencies, configurations, or setup steps required
14+
- Ensure that the documentation is kept up-to-date with code changes
15+
16+
## Communication Style
17+
- Use simple, straightforward language
18+
- Break down complex concepts into manageable sections
19+
- Use bullet points, numbered lists, and headings to organize information
20+
- Provide context and background information when necessary
21+
- Write WebAPI endpoint documentation to be used by MCP server and AI agent along with developers
22+
- Write the web API endpoint documentation in the OpenAPI format, with short summaries and descriptions for each endpoint, including request and response schemas.

.github/copilot-instructions.md

Lines changed: 5 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,6 @@
1-
# Genocs CLI - Copilot Instructions
1+
---
2+
applyTo: '**'
3+
---
24

3-
## Project Overview
4-
This is a .NET 9 CLI tool packaged as a global dotnet tool (`genocs`) that provides templates for Genocs microservice solutions. The tool generates project scaffolding for various frontend and backend architectures.
5-
6-
## Architecture & Structure
7-
8-
### Core Components
9-
- **Single executable**: `src/Program.cs` contains all CLI command logic in a top-level program pattern
10-
- **Template bootstrapping**: Commands call specific `Bootstrap*SolutionAsync()` methods that invoke `dotnet new` with Genocs templates
11-
- **Command pattern**: Simple string parsing with format `genocs <template-type> <command> <project-name>`
12-
13-
### Supported Templates
14-
Available via commands like `genocs [template] new CompanyName.ProjectName`:
15-
- `angular` - Angular frontend projects
16-
- `react` - React frontend projects
17-
- `blazor-clean` - Clean Blazor applications
18-
- `blazor-wasm` - Blazor WebAssembly projects
19-
- `clean-webapi` - Clean Architecture Web APIs
20-
- `libra-webapi` - Libra Web API template
21-
- `micro-webapi` - Microservice Web API template
22-
23-
### Project Naming Convention
24-
Uses `ToCapitalCase()` extension method (in `StringExtensions.cs`) to convert input like "company.project" to "Company.Project" format for proper C# namespace conventions.
25-
26-
## Development Workflows
27-
28-
### Building & Testing
29-
```bash
30-
# From repository root
31-
dotnet build
32-
dotnet run --project src/genocs.cli.csproj -- genocs -i
33-
34-
# From src/ directory
35-
dotnet build genocs.cli.csproj
36-
dotnet run -f net9.0 genocs -i
37-
```
38-
39-
### Local Installation & Testing
40-
```bash
41-
# Pack for local installation
42-
dotnet pack --output nupkgs
43-
dotnet tool install --global --add-source ./nupkgs genocs.cli
44-
45-
# Test template installation
46-
genocs install # or genocs i
47-
```
48-
49-
### Template Management
50-
- `genocs install|i` - Installs/updates Genocs templates from remote repositories
51-
- `genocs update|u` - Alias for install command
52-
- Templates are installed via `dotnet new install` commands in bootstrap methods
53-
54-
## Build Configuration
55-
56-
### Project Structure
57-
- **Single project solution**: Only `src/genocs.cli.csproj` with solution items folder
58-
- **Global build props**: `Directory.Build.props` enforces StyleCop, Roslynator analyzers, nullable reference types
59-
- **Tool packaging**: Configured as `<PackAsTool>true</PackAsTool>` with command name `genocs`
60-
61-
### Code Quality
62-
- **StyleCop + Roslynator**: Enforced via `Directory.Build.props` with custom `stylecop.json` rules
63-
- **Nullable enabled**: All projects use `<Nullable>enable</Nullable>`
64-
- **Documentation**: `GenerateDocumentationFile` enabled for XML docs
65-
- **Global using**: `System.Guid` aliased as `DefaultIdType`
66-
67-
## Key Patterns
68-
69-
### Command Parsing
70-
Simple imperative parsing in `Program.cs`:
71-
```csharp
72-
string firstArg = args[0].Trim().ToLower();
73-
if (firstArg == "install" || firstArg == "i" || firstArg == "update" || firstArg == "u")
74-
{
75-
await InstallTemplates();
76-
return;
77-
}
78-
```
79-
80-
### Error Handling
81-
Basic validation with console output:
82-
```csharp
83-
if (args.Length != 3)
84-
{
85-
Console.WriteLine("Invalid command. Use something like: genocs angular new <CompanyName.ProjectName>");
86-
return;
87-
}
88-
```
89-
90-
### Resource Management
91-
- `MainResource.resx` for embedded strings/resources
92-
- `Figgle` dependency for ASCII art rendering
93-
- `icon.png` and license files embedded in NuGet package
94-
95-
## CI/CD Pipeline
96-
- **GitHub Actions**: `build_and_test.yml` runs on .NET 9 with restore, build, test, pack
97-
- **NuGet publishing**: Separate workflow for package deployment
98-
- **Version management**: `PackageVersion` in csproj, uses SemVer
99-
100-
## Dependencies & External Integration
101-
- **Figgle**: ASCII art rendering for CLI branding
102-
- **Genocs Templates**: External template repositories installed via `dotnet new install`
103-
- **NuGet**: Published as global tool with command name `genocs`
5+
You are a experienced software engineer. Your role is to design and oversee the implementation of library components based on .NET Core. Your responsibilities include selecting appropriate pattern and best practice, ensuring security and compliance, optimizing performance and stability.
6+
Your expertise in Microsoft .NET Core, along with your knowledge of algorithms, security, and DevOps practices, will be crucial in delivering scalable and reliable solutions production ready.

.github/instructions/dotnet_solution_architect.instructions.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

.github/workflows/build_and_test.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ name: Build test and pack
22

33
on:
44
push:
5-
branches: ["main"]
6-
5+
branches: [main, develop]
76
pull_request:
8-
branches: ["main"]
7+
branches: [main, develop]
98

109
jobs:
1110
build:

.github/workflows/nuget-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
run: dotnet test --no-build --verbosity normal
4242

4343
- name: Pack
44-
run: dotnet pack -c Debug -o out -p:PackageVersion=${{github.event.inputs.version}} --no-build --verbosity normal
44+
run: dotnet pack -c Debug -o out -p:PackageVersion=${{ github.event.inputs.version }} --no-build --verbosity normal
4545

4646
- name: Push packages to Nuget
47-
run: dotnet nuget push ./out/*.nupkg -k ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols
47+
run: dotnet nuget push ./out/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Nullable>enable</Nullable>
1010
</PropertyGroup>
1111
<ItemGroup>
12-
<PackageReference Include="Roslynator.Analyzers" Version="4.14.0">
12+
<PackageReference Include="Roslynator.Analyzers" Version="4.14.1">
1313
<PrivateAssets>all</PrivateAssets>
1414
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
1515
</PackageReference>

src/genocs.cli.csproj.user

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)