- Notifications
You must be signed in to change notification settings - Fork 0
Promote develop to main: agent-comms + supported-platforms + C# test/logging rules#271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -156,7 +156,7 @@ Note: Code snippets are illustrative examples only. Replace namespaces/types to | ||
| global using System; | ||
| global using System.Net.Http; | ||
| global using System.Threading.Tasks; | ||
| global using Serilog; | ||
| global using Microsoft.Extensions.Logging; | ||
| ``` | ||
| 2. **Usings placement**: Outside namespace, sorted with `System` directives first | ||
| @@ -245,15 +245,13 @@ Follow the scope hierarchy in [Analyzer Diagnostics and Suppressions][analyzer-d | ||
| #### Error Handling and Logging | ||
| 1. **Serilog logging**: Use structured logging | ||
| 1. **Structured logging**: Use structured message templates - Serilog is the **application's** concrete backend; a library never references it (see item 2) | ||
| ```csharp | ||
| logger.Error(exception, "{Function}", function); | ||
| logger.LogError(exception, "{Function}", function); | ||
| ``` | ||
| 2. **Library log configuration**: Libraries must expose logging configuration | ||
| - Provide options or settings to supply an `ILoggerFactory` and/or `ILogger` | ||
| - Offer a global fallback logger for static usage when needed | ||
| 2. **Libraries log through abstractions, never a concrete backend.** A NuGet **library** depends only on `Microsoft.Extensions.Logging.Abstractions` and exposes an `ILoggerFactory` seam - a settable global factory defaulting to `NullLoggerFactory` (fallback `NullLogger.Instance`) with `SetFactory`/`TrySetFactory`, and/or an `ILoggerFactory`/`ILogger` parameter in its API. It must **not** reference Serilog or any sink - that forces a logging framework on every consumer and drags in AOT-incompatible dependencies. The consuming **application** owns the concrete logger (Serilog is fine there), bridges it to `ILoggerFactory` (e.g. `SerilogLoggerFactory` from `Serilog.Extensions.Logging`), and injects it. Reference: `LanguageTags` - `LogOptions` in the library; the CLI's `LoggerFactory` builds the Serilog-backed factory and injects it via `LogOptions.SetFactory`. | ||
ptr727 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| 3. **CallerMemberName**: Use for automatic function name tracking | ||
| @@ -294,7 +292,7 @@ Follow the scope hierarchy in [Analyzer Diagnostics and Suppressions][analyzer-d | ||
| #### Testing Conventions | ||
| 1. **Framework**: xUnit with AwesomeAssertions | ||
| 1. **Framework**: **xUnit v3 or later** (the `xunit.v3` package, never the legacy v2 `xunit` package) with **AwesomeAssertions** for every assertion; native xUnit asserts (`Assert.Equal`, `Assert.True`, ...) are not allowed - use the fluent `.Should()` API | ||
| ```csharp | ||
| [Fact] | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.