Skip to content

Commit 43ae92d

Browse files
authored
Merge pull request #159 from marcominerva/develop
Update workflows, dependencies, and add guidelines
2 parents 4e24e25 + 4a30e34 commit 43ae92d

File tree

15 files changed

+120
-90
lines changed

15 files changed

+120
-90
lines changed

.github/copilot-instructions.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
## General
2+
3+
- Make only high confidence suggestions when reviewing code changes.
4+
- Always use the latest version C#, currently C# 13 features.
5+
- Write code that is clean, maintainable, and easy to understand.
6+
- Only add comments rarely to explain why a non-intuitive solution was used. The code should be self-explanatory otherwise.
7+
- Don't add the UTF-8 BOM to files unless they have non-ASCII characters.
8+
- Never change global.json unless explicitly asked to.
9+
- Never change package.json or package-lock.json files unless explicitly asked to.
10+
- Never change NuGet.config files unless explicitly asked to.
11+
12+
## Code Style
13+
14+
### Formatting
15+
16+
- Apply code-formatting style defined in `.editorconfig`.
17+
- Use primary constructors where applicable.
18+
- Prefer file-scoped namespace declarations and single-line using directives.
19+
- Insert a newline before the opening curly brace of any code block (e.g., after `if`, `for`, `while`, `foreach`, `using`, `try`, etc.).
20+
- Ensure that the final return statement of a method is on its own line.
21+
- Use pattern matching and switch expressions wherever possible.
22+
- Prefer using collection expressions when possible
23+
- Use `is` pattern matching instead of `as` and null checks
24+
- Use `nameof` instead of string literals when referring to member names.
25+
- Prefer `?.` if applicable (e.g. `scope?.Dispose()`).
26+
- Use `ObjectDisposedException.ThrowIf` where applicable.
27+
- Use `ArgumentNullException.ThrowIfNull` to validate input paramters.
28+
- If you add new code files, ensure they are listed in the csproj file (if other files in that folder are listed there) so they build.
29+
30+
### Nullable Reference Types
31+
32+
- Declare variables non-nullable, and check for `null` at entry points.
33+
- Always use `is null` or `is not null` instead of `== null` or `!= null`.
34+
- Trust the C# null annotations and don't add null checks when the type system says a value cannot be null.
35+
36+
## Architecture and Design Patterns
37+
38+
### Asynchronous Programming
39+
40+
- Provide both synchronous and asynchronous versions of methods where appropriate.
41+
- Use the `Async` suffix for asynchronous methods.
42+
- Return `Task` or `ValueTask` from asynchronous methods.
43+
- Use `CancellationToken` parameters to support cancellation.
44+
- Avoid async void methods except for event handlers.
45+
- Call `ConfigureAwait(false)` on awaited calls to avoid deadlocks.
46+
47+
### Error Handling
48+
49+
- Use appropriate exception types.
50+
- Include helpful error messages.
51+
- Avoid catching exceptions without rethrowing them.
52+
53+
### Performance Considerations
54+
55+
- Be mindful of performance implications, especially for database operations.
56+
- Avoid unnecessary allocations.
57+
- Consider using more efficient code that is expected to be on the hot path, even if it is less readable.
58+
59+
### Implementation Guidelines
60+
61+
- Write code that is secure by default. Avoid exposing potentially private or sensitive data.
62+
- Make code NativeAOT compatible when possible. This means avoiding dynamic code generation, reflection, and other features that are not compatible. with NativeAOT. If not possible, mark the code with an appropriate annotation or throw an exception.
63+
64+
## Documentation
65+
66+
- Include XML documentation for all public APIs. Mention the purpose, intent, and 'the why' of the code, so developers unfamiliar with the project can better understand it. If comments already exist, update them to meet the before mentioned criteria if needed. Use the full syntax of XML Doc Comments to make them as awesome as possible including references to types. Don't add any documentation that is obvious for even novice developers by reading the code.
67+
- Add proper `<remarks>` tags with links to relevant documentation where helpful.
68+
- For keywords like `null`, `true` or `false` use `<see langword="*" />` tags.
69+
- Include code examples in documentation where appropriate.
70+
- Overriding members should inherit the XML documentation from the base type via `/// <inheritdoc />`.
71+
72+
## Markdown
73+
- Use Markdown for documentation files (e.g., README.md).
74+
- Use triple backticks for code blocks, JSON snippets and bash commands, specifying the language (e.g., ```csharp, ```json and ```bash).
75+
76+
## Testing
77+
78+
- When adding new unit tests, strongly prefer to add them to existing test code files rather than creating new code files.
79+
- We use xUnit SDK v3 for tests.
80+
- Do not emit "Act", "Arrange" or "Assert" comments.
81+
- Use NSubstitute for mocking in tests.
82+
- Copy existing style in nearby files for test method names and capitalization.
83+
- When running tests, if possible use filters and check test run counts, or look at test logs, to ensure they actually ran.
84+
- Do not finish work with any tests commented out or disabled that were not previously commented out or disabled.

.github/workflows/codeql.yml

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

.github/workflows/linter.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Lint Code Base
22

3+
permissions:
4+
contents: read
5+
36
#############################
47
# Start the job on all push #
58
#############################
@@ -31,7 +34,7 @@ jobs:
3134
# Checkout the code base #
3235
##########################
3336
- name: Checkout Code
34-
uses: actions/checkout@v3
37+
uses: actions/checkout@v4
3538
with:
3639
# Full git history is needed to get a proper list of changed files within `super-linter`
3740
fetch-depth: 0

.github/workflows/publish.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
name: Publish SimpleAuthentication on NuGet
2+
3+
permissions:
4+
contents: read
5+
packages: write
6+
actions: write
27

38
on:
49
push:
@@ -19,12 +24,12 @@ jobs:
1924

2025
steps:
2126
- name: Checkout
22-
uses: actions/checkout@v3
27+
uses: actions/checkout@v4
2328
with:
2429
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
2530

2631
- name: Setup .NET SDK ${{ env.NET_VERSION }}
27-
uses: actions/setup-dotnet@v3
32+
uses: actions/setup-dotnet@v4
2833
with:
2934
dotnet-version: ${{ env.NET_VERSION }}
3035
dotnet-quality: 'ga'

.github/workflows/publish_abstractions.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
name: Publish Abstractions on NuGet
2+
3+
permissions:
4+
contents: read
5+
packages: write
6+
actions: write
27

38
on:
49
push:
@@ -20,12 +25,12 @@ jobs:
2025

2126
steps:
2227
- name: Checkout
23-
uses: actions/checkout@v3
28+
uses: actions/checkout@v4
2429
with:
2530
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
2631

2732
- name: Setup .NET SDK ${{ env.NET_VERSION }}
28-
uses: actions/setup-dotnet@v3
33+
uses: actions/setup-dotnet@v4
2934
with:
3035
dotnet-version: ${{ env.NET_VERSION }}
3136
dotnet-quality: 'ga'

.github/workflows/publish_swashbuckle.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
name: Publish Swashbuckle for Simple Authentication on NuGet
2+
3+
permissions:
4+
contents: read
5+
packages: write
6+
actions: write
27

38
on:
49
push:
@@ -20,12 +25,12 @@ jobs:
2025

2126
steps:
2227
- name: Checkout
23-
uses: actions/checkout@v3
28+
uses: actions/checkout@v4
2429
with:
2530
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
2631

2732
- name: Setup .NET SDK ${{ env.NET_VERSION }}
28-
uses: actions/setup-dotnet@v3
33+
uses: actions/setup-dotnet@v4
2934
with:
3035
dotnet-version: ${{ env.NET_VERSION }}
3136
dotnet-quality: 'ga'

SimpleAuthentication.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A025126A-3557-4B63-AC19-C8851FB3B88C}"
99
ProjectSection(SolutionItems) = preProject
1010
.editorconfig = .editorconfig
11+
.github\copilot-instructions.md = .github\copilot-instructions.md
1112
src\Directory.Build.props = src\Directory.Build.props
1213
EndProjectSection
1314
EndProject

samples/Controllers/ApiKeySample/ApiKeySample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.1" />
10+
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.3" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

samples/Controllers/BasicAuthenticationSample/BasicAuthenticationSample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.1" />
10+
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.3" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

samples/Controllers/JwtBearerSample/JwtBearerSample.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.1" />
11-
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="9.0.1" />
10+
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.3" />
11+
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="9.0.3" />
1212
</ItemGroup>
1313

1414
<ItemGroup>

0 commit comments

Comments
 (0)