From 9d577799fe35f7cd344e8d143180f20bc175fc1e Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Sat, 15 Mar 2025 15:02:22 +0000 Subject: [PATCH 1/3] Remove left-overs from SDK workaround (#1699) --- .github/workflows/build.yml | 3 --- .github/workflows/codeql.yml | 5 ++--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 720b7fe6d8..37878e5e4a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,7 +45,6 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - # Block buggy release from February 11, 2025 dotnet-version: | 8.0.* 9.0.* @@ -164,7 +163,6 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - # Block buggy release from February 11, 2025 dotnet-version: | 8.0.* 9.0.* @@ -220,7 +218,6 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - # Block buggy release from February 11, 2025 dotnet-version: | 8.0.* 9.0.* diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 8e430ee6a4..d3d4db6142 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -26,10 +26,9 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - # Block buggy release from February 11, 2025 dotnet-version: | - 8.0.309 - 9.0.103 + 8.0.* + 9.0.* - name: Git checkout uses: actions/checkout@v4 - name: Initialize CodeQL From 424b95d17227b940da1fec9201ca8a12ae0b2cde Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Sat, 22 Mar 2025 14:34:39 +0100 Subject: [PATCH 2/3] Update http links to https --- PackageReadme.md | 2 +- README.md | 4 ++-- src/Examples/GettingStarted/README.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/PackageReadme.md b/PackageReadme.md index f57386041b..a6d0017f6a 100644 --- a/PackageReadme.md +++ b/PackageReadme.md @@ -1,4 +1,4 @@ -A framework for building [JSON:API](http://jsonapi.org/) compliant REST APIs using .NET Core and Entity Framework Core. Includes support for [Atomic Operations](https://jsonapi.org/ext/atomic/). +A framework for building [JSON:API](https://jsonapi.org/) compliant REST APIs using .NET Core and Entity Framework Core. Includes support for [Atomic Operations](https://jsonapi.org/ext/atomic/). The ultimate goal of this library is to eliminate as much boilerplate as possible by offering out-of-the-box features such as sorting, filtering and pagination. You just need to focus on defining the resources and implementing your custom business logic. This library has been designed around dependency injection, making extensibility incredibly easy. diff --git a/README.md b/README.md index 8bd84b3d9c..0027580d78 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # JsonApiDotNetCore -A framework for building [JSON:API](http://jsonapi.org/) compliant REST APIs using .NET Core and Entity Framework Core. Includes support for [Atomic Operations](https://jsonapi.org/ext/atomic/). +A framework for building [JSON:API](https://jsonapi.org/) compliant REST APIs using .NET Core and Entity Framework Core. Includes support for [Atomic Operations](https://jsonapi.org/ext/atomic/). [![Build](https://github.com/json-api-dotnet/JsonApiDotNetCore/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/json-api-dotnet/JsonApiDotNetCore/actions/workflows/build.yml?query=branch%3Amaster) [![Coverage](https://codecov.io/gh/json-api-dotnet/JsonApiDotNetCore/branch/master/graph/badge.svg?token=pn036tWV8T)](https://codecov.io/gh/json-api-dotnet/JsonApiDotNetCore) [![NuGet](https://img.shields.io/nuget/v/JsonApiDotNetCore.svg)](https://www.nuget.org/packages/JsonApiDotNetCore/) [![Chat](https://badges.gitter.im/json-api-dotnet-core/Lobby.svg)](https://gitter.im/json-api-dotnet-core/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![FIRST-TIMERS](https://img.shields.io/badge/first--timers--only-friendly-blue.svg)](http://www.firsttimersonly.com/) +[![FIRST-TIMERS](https://img.shields.io/badge/first--timers--only-friendly-blue.svg)](https://www.firsttimersonly.com/) The ultimate goal of this library is to eliminate as much boilerplate as possible by offering out-of-the-box features such as sorting, filtering and pagination. You just need to focus on defining the resources and implementing your custom business logic. This library has been designed around dependency injection, making extensibility incredibly easy. diff --git a/src/Examples/GettingStarted/README.md b/src/Examples/GettingStarted/README.md index 563899a827..8d8da60bc8 100644 --- a/src/Examples/GettingStarted/README.md +++ b/src/Examples/GettingStarted/README.md @@ -11,4 +11,4 @@ For further documentation and implementation of a JsonApiDotNetCore Application Repository: https://github.com/json-api-dotnet/JsonApiDotNetCore -Documentation: http://www.jsonapi.net +Documentation: https://www.jsonapi.net From cca390809168955f3fa64d7c9d5ea70d560f598c Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Sat, 29 Mar 2025 00:39:46 +0100 Subject: [PATCH 3/3] Strip namespaces when unit tests log to the Output Window (#1706) --- test/TestBuildingBlocks/LogOutputFields.cs | 10 +++--- .../TestBuildingBlocks/XUnitLoggerProvider.cs | 36 ++++++++++++++++--- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/test/TestBuildingBlocks/LogOutputFields.cs b/test/TestBuildingBlocks/LogOutputFields.cs index 02ea580eff..c6a1475579 100644 --- a/test/TestBuildingBlocks/LogOutputFields.cs +++ b/test/TestBuildingBlocks/LogOutputFields.cs @@ -8,10 +8,12 @@ public enum LogOutputFields { None = 0, Level = 1, - Category = 1 << 1, - Message = 1 << 2, - Exception = 1 << 3, - Scopes = 1 << 4, + CategoryName = 1 << 1, + CategoryNamespace = 1 << 2, + Message = 1 << 3, + Exception = 1 << 4, + Scopes = 1 << 5, + Category = CategoryName | CategoryNamespace, All = Level | Category | Message | Exception | Scopes } diff --git a/test/TestBuildingBlocks/XUnitLoggerProvider.cs b/test/TestBuildingBlocks/XUnitLoggerProvider.cs index a6214032af..26c15d575b 100644 --- a/test/TestBuildingBlocks/XUnitLoggerProvider.cs +++ b/test/TestBuildingBlocks/XUnitLoggerProvider.cs @@ -8,11 +8,12 @@ namespace TestBuildingBlocks; // Based on https://www.meziantou.net/how-to-get-asp-net-core-logs-in-the-output-of-xunit-tests.htm. public sealed class XUnitLoggerProvider : ILoggerProvider { + private const LogOutputFields DefaultLogOutputFields = LogOutputFields.All & ~LogOutputFields.CategoryNamespace; private readonly ITestOutputHelper _testOutputHelper; private readonly LogOutputFields _outputFields; private readonly string? _categoryPrefixFilter; - public XUnitLoggerProvider(ITestOutputHelper testOutputHelper, string? categoryPrefixFilter, LogOutputFields outputFields = LogOutputFields.All) + public XUnitLoggerProvider(ITestOutputHelper testOutputHelper, string? categoryPrefixFilter, LogOutputFields outputFields = DefaultLogOutputFields) { ArgumentNullException.ThrowIfNull(testOutputHelper); @@ -41,7 +42,34 @@ private sealed class XUnitLogger(ITestOutputHelper testOutputHelper, LogOutputFi { private readonly ITestOutputHelper _testOutputHelper = testOutputHelper; private readonly LogOutputFields _outputFields = outputFields; - private readonly string _categoryName = categoryName; + private readonly string? _categoryText = GetCategoryText(categoryName, outputFields); + + private static string? GetCategoryText(string categoryName, LogOutputFields outputFields) + { + if (outputFields.HasFlag(LogOutputFields.Category)) + { + return categoryName; + } + + bool hasName = outputFields.HasFlag(LogOutputFields.CategoryName); + bool hasNamespace = outputFields.HasFlag(LogOutputFields.CategoryNamespace); + + if (hasName || hasNamespace) + { + // Microsoft.Extensions.Logging.LoggerFactory.CreateLogger(Type) removes generic type parameters + // and replaces '+' (nested class) with '.'. + int lastDotIndex = categoryName.LastIndexOf('.'); + + if (lastDotIndex == -1) + { + return hasName ? categoryName : string.Empty; + } + + return hasName ? categoryName[(lastDotIndex + 1)..] : categoryName[..lastDotIndex]; + } + + return null; + } public bool IsEnabled(LogLevel logLevel) { @@ -68,7 +96,7 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except builder.Append(logLevelString); } - if (_outputFields.HasFlag(LogOutputFields.Category)) + if (_categoryText != null) { if (builder.Length > 0) { @@ -76,7 +104,7 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except } builder.Append('['); - builder.Append(_categoryName); + builder.Append(_categoryText); builder.Append(']'); }