Skip to content

Commit d956f04

Browse files
CopilotKSemenenko
andcommitted
Add comprehensive README and EditorConfig
Co-authored-by: KSemenenko <4385716+KSemenenko@users.noreply.github.com>
1 parent add0f57 commit d956f04

File tree

2 files changed

+319
-1
lines changed

2 files changed

+319
-1
lines changed

.editorconfig

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# All files
7+
[*]
8+
charset = utf-8
9+
indent_style = space
10+
indent_size = 4
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
# XML project files
15+
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
16+
indent_size = 2
17+
18+
# XML config files
19+
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
20+
indent_size = 2
21+
22+
# JSON files
23+
[*.json]
24+
indent_size = 2
25+
26+
# YAML files
27+
[*.{yml,yaml}]
28+
indent_size = 2
29+
30+
# Shell scripts
31+
[*.sh]
32+
end_of_line = lf
33+
34+
# Markdown files
35+
[*.md]
36+
trim_trailing_whitespace = false
37+
38+
# Dotnet code style settings
39+
[*.{cs,vb}]
40+
# Organize usings
41+
dotnet_sort_system_directives_first = true
42+
dotnet_separate_import_directive_groups = false
43+
44+
# this. preferences
45+
dotnet_style_qualification_for_field = false:warning
46+
dotnet_style_qualification_for_property = false:warning
47+
dotnet_style_qualification_for_method = false:warning
48+
dotnet_style_qualification_for_event = false:warning
49+
50+
# Language keywords vs BCL types preferences
51+
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
52+
dotnet_style_predefined_type_for_member_access = true:warning
53+
54+
# Parentheses preferences
55+
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
56+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
57+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
58+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
59+
60+
# Modifier preferences
61+
dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning
62+
dotnet_style_readonly_field = true:warning
63+
64+
# Expression-level preferences
65+
dotnet_style_object_initializer = true:suggestion
66+
dotnet_style_collection_initializer = true:suggestion
67+
dotnet_style_explicit_tuple_names = true:suggestion
68+
dotnet_style_null_propagation = true:suggestion
69+
dotnet_style_coalesce_expression = true:suggestion
70+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
71+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
72+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
73+
dotnet_style_prefer_auto_properties = true:silent
74+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
75+
dotnet_style_prefer_conditional_expression_over_return = true:silent
76+
77+
# CSharp code style settings
78+
[*.cs]
79+
# var preferences
80+
csharp_style_var_for_built_in_types = true:silent
81+
csharp_style_var_when_type_is_apparent = true:suggestion
82+
csharp_style_var_elsewhere = true:silent
83+
84+
# Expression-bodied members
85+
csharp_style_expression_bodied_methods = false:silent
86+
csharp_style_expression_bodied_constructors = false:silent
87+
csharp_style_expression_bodied_operators = false:silent
88+
csharp_style_expression_bodied_properties = true:suggestion
89+
csharp_style_expression_bodied_indexers = true:suggestion
90+
csharp_style_expression_bodied_accessors = true:suggestion
91+
92+
# Pattern matching preferences
93+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
94+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
95+
96+
# Null-checking preferences
97+
csharp_style_throw_expression = true:suggestion
98+
csharp_style_conditional_delegate_call = true:suggestion
99+
100+
# Modifier preferences
101+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
102+
103+
# Expression-level preferences
104+
csharp_prefer_braces = true:silent
105+
csharp_style_deconstructed_variable_declaration = true:suggestion
106+
csharp_prefer_simple_default_expression = true:suggestion
107+
csharp_style_pattern_local_over_anonymous_function = true:suggestion
108+
csharp_style_inlined_variable_declaration = true:suggestion
109+
110+
# New line preferences
111+
csharp_new_line_before_open_brace = all
112+
csharp_new_line_before_else = true
113+
csharp_new_line_before_catch = true
114+
csharp_new_line_before_finally = true
115+
csharp_new_line_before_members_in_object_initializers = true
116+
csharp_new_line_before_members_in_anonymous_types = true
117+
csharp_new_line_between_query_expression_clauses = true
118+
119+
# Indentation preferences
120+
csharp_indent_case_contents = true
121+
csharp_indent_switch_labels = true
122+
csharp_indent_labels = flush_left
123+
124+
# Space preferences
125+
csharp_space_after_cast = false
126+
csharp_space_after_keywords_in_control_flow_statements = true
127+
csharp_space_between_method_call_parameter_list_parentheses = false
128+
csharp_space_between_method_declaration_parameter_list_parentheses = false
129+
csharp_space_between_parentheses = false
130+
csharp_space_before_colon_in_inheritance_clause = true
131+
csharp_space_after_colon_in_inheritance_clause = true
132+
csharp_space_around_binary_operators = before_and_after
133+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
134+
csharp_space_between_method_call_name_and_opening_parenthesis = false
135+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
136+
137+
# Wrapping preferences
138+
csharp_preserve_single_line_statements = true
139+
csharp_preserve_single_line_blocks = true

README.md

Lines changed: 180 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,180 @@
1-
# ProjectTemplate
1+
# ProjectTemplate
2+
3+
A .NET 9 project template with [.NET Aspire](https://learn.microsoft.com/en-us/dotnet/aspire/) orchestration, including a sample API with tests and automated CI/CD pipelines.
4+
5+
## Features
6+
7+
-**ASP.NET Core Web API** - Minimal API with weather forecast endpoint
8+
- 🚀 **.NET Aspire** - Modern cloud-native application orchestration
9+
- 🧪 **xUnit Tests** - Integration tests using WebApplicationFactory
10+
- 📦 **Service Defaults** - Shared telemetry, service discovery, and resilience patterns
11+
- 🔄 **GitHub Actions** - Automated CI/CD pipelines for testing, security analysis, and releases
12+
- 📊 **Code Coverage** - Integrated with Codecov for coverage tracking
13+
- 🔒 **CodeQL Analysis** - Automated security scanning on every push
14+
15+
## Project Structure
16+
17+
```
18+
ProjectTemplate/
19+
├── src/
20+
│ ├── ProjectTemplate.Api/ # ASP.NET Core Web API
21+
│ ├── ProjectTemplate.AppHost/ # Aspire orchestration host
22+
│ └── ProjectTemplate.ServiceDefaults/ # Shared configuration and services
23+
├── tests/
24+
│ └── ProjectTemplate.Tests/ # Integration tests
25+
├── .github/
26+
│ └── workflows/
27+
│ ├── ci.yml # Build and test on PR
28+
│ ├── codeql-analysis.yml # Security analysis
29+
│ └── release.yml # Release and publish to NuGet
30+
└── Directory.Build.props # Shared build properties and versioning
31+
```
32+
33+
## Getting Started
34+
35+
### Prerequisites
36+
37+
- [.NET 9 SDK](https://dotnet.microsoft.com/download/dotnet/9.0)
38+
- [Docker Desktop](https://www.docker.com/products/docker-desktop) (for Aspire Dashboard)
39+
40+
### Installation
41+
42+
1. Install the .NET Aspire workload:
43+
```bash
44+
dotnet workload install aspire
45+
```
46+
47+
2. Clone the repository:
48+
```bash
49+
git clone https://github.com/managedcode/ProjectTemplate.git
50+
cd ProjectTemplate
51+
```
52+
53+
3. Restore dependencies:
54+
```bash
55+
dotnet restore
56+
```
57+
58+
### Running the Application
59+
60+
#### Using .NET Aspire AppHost (Recommended)
61+
62+
This will start the API and open the Aspire Dashboard:
63+
64+
```bash
65+
dotnet run --project src/ProjectTemplate.AppHost
66+
```
67+
68+
The Aspire Dashboard will be available at the URL shown in the console output (typically `http://localhost:15888`).
69+
70+
#### Running the API Directly
71+
72+
```bash
73+
dotnet run --project src/ProjectTemplate.Api
74+
```
75+
76+
The API will be available at:
77+
- HTTP: `http://localhost:5000`
78+
- HTTPS: `https://localhost:5001`
79+
80+
### Running Tests
81+
82+
```bash
83+
dotnet test
84+
```
85+
86+
### Building
87+
88+
```bash
89+
dotnet build --configuration Release
90+
```
91+
92+
## API Endpoints
93+
94+
### Weather Forecast
95+
- **GET** `/weatherforecast` - Returns a 5-day weather forecast
96+
97+
### Health & Metrics (via ServiceDefaults)
98+
- **GET** `/health` - Health check endpoint
99+
- **GET** `/alive` - Liveness probe
100+
- **GET** `/metrics` - Prometheus metrics
101+
102+
## Development
103+
104+
### Adding a New Service
105+
106+
1. Create a new project in the `src` folder
107+
2. Reference `ProjectTemplate.ServiceDefaults` to get shared configurations
108+
3. Add the project to the AppHost in `src/ProjectTemplate.AppHost/Program.cs`:
109+
110+
```csharp
111+
var myService = builder.AddProject<Projects.MyService>("myservice");
112+
```
113+
114+
### Running Tests in Development
115+
116+
The project includes two types of tests:
117+
118+
1. **WebApplicationFactory Tests** - Run in any environment (CI/CD friendly)
119+
2. **Aspire Integration Tests** - Require the DCP (Development Control Plane), skipped in CI
120+
121+
## CI/CD Pipelines
122+
123+
### CI Workflow (`.github/workflows/ci.yml`)
124+
Runs on every pull request and push to main:
125+
- Builds the solution
126+
- Runs all tests
127+
- Collects code coverage
128+
- Uploads coverage to Codecov
129+
130+
### CodeQL Workflow (`.github/workflows/codeql-analysis.yml`)
131+
Runs on:
132+
- Every push to main
133+
- Every pull request
134+
- Weekly schedule (Monday at midnight)
135+
136+
Performs automated security scanning to detect vulnerabilities.
137+
138+
### Release Workflow (`.github/workflows/release.yml`)
139+
Runs on push to main:
140+
- Builds and tests the solution
141+
- Packs NuGet packages
142+
- Publishes to NuGet.org (requires `NUGET_API_KEY` secret)
143+
- Creates GitHub release with auto-generated release notes
144+
- Tags the release
145+
146+
## Configuration
147+
148+
### Versioning
149+
150+
Version is managed in `Directory.Build.props`:
151+
152+
```xml
153+
<Version>1.0.0</Version>
154+
```
155+
156+
Update this version to release new versions to NuGet.
157+
158+
### GitHub Secrets
159+
160+
To enable the full CI/CD pipeline, configure these secrets in your GitHub repository:
161+
162+
- `NUGET_API_KEY` - API key for publishing to NuGet.org
163+
- `CODECOV_TOKEN` - Token for uploading coverage to Codecov (optional)
164+
165+
## Technologies
166+
167+
- [.NET 9](https://dotnet.microsoft.com/download/dotnet/9.0)
168+
- [.NET Aspire](https://learn.microsoft.com/en-us/dotnet/aspire/)
169+
- [ASP.NET Core](https://docs.microsoft.com/aspnet/core)
170+
- [xUnit](https://xunit.net/)
171+
- [OpenTelemetry](https://opentelemetry.io/)
172+
- [GitHub Actions](https://github.com/features/actions)
173+
174+
## License
175+
176+
MIT
177+
178+
## Contributing
179+
180+
Contributions are welcome! Please feel free to submit a Pull Request.

0 commit comments

Comments
 (0)