Skip to content

Commit 5d49ecb

Browse files
authored
Merge master into openapi (#1707)
* Remove left-overs from SDK workaround (#1699) * Update http links to https * Strip namespaces when unit tests log to the Output Window (#1706)
2 parents a771afa + fde8e80 commit 5d49ecb

File tree

7 files changed

+44
-18
lines changed

7 files changed

+44
-18
lines changed

Diff for: .github/workflows/build.yml

-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ jobs:
4545
- name: Setup .NET
4646
uses: actions/setup-dotnet@v4
4747
with:
48-
# Block buggy release from February 11, 2025
4948
dotnet-version: |
5049
8.0.*
5150
9.0.*
@@ -164,7 +163,6 @@ jobs:
164163
- name: Setup .NET
165164
uses: actions/setup-dotnet@v4
166165
with:
167-
# Block buggy release from February 11, 2025
168166
dotnet-version: |
169167
8.0.*
170168
9.0.*
@@ -220,7 +218,6 @@ jobs:
220218
- name: Setup .NET
221219
uses: actions/setup-dotnet@v4
222220
with:
223-
# Block buggy release from February 11, 2025
224221
dotnet-version: |
225222
8.0.*
226223
9.0.*

Diff for: .github/workflows/codeql.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ jobs:
2626
- name: Setup .NET
2727
uses: actions/setup-dotnet@v4
2828
with:
29-
# Block buggy release from February 11, 2025
3029
dotnet-version: |
31-
8.0.309
32-
9.0.103
30+
8.0.*
31+
9.0.*
3332
- name: Git checkout
3433
uses: actions/checkout@v4
3534
- name: Initialize CodeQL

Diff for: PackageReadme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
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/).
1+
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/).
22

33
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.
44

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<a href="https://www.jsonapi.net"><img src="docs/home/assets/img/logo.svg" style="height: 345px; width: 345px"/></a>
22

33
# JsonApiDotNetCore
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/).
4+
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/).
55

66
[![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)
77
[![Coverage](https://codecov.io/gh/json-api-dotnet/JsonApiDotNetCore/branch/master/graph/badge.svg?token=pn036tWV8T)](https://codecov.io/gh/json-api-dotnet/JsonApiDotNetCore)
88
[![NuGet](https://img.shields.io/nuget/v/JsonApiDotNetCore.svg)](https://www.nuget.org/packages/JsonApiDotNetCore/)
99
[![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)
10-
[![FIRST-TIMERS](https://img.shields.io/badge/first--timers--only-friendly-blue.svg)](http://www.firsttimersonly.com/)
10+
[![FIRST-TIMERS](https://img.shields.io/badge/first--timers--only-friendly-blue.svg)](https://www.firsttimersonly.com/)
1111

1212
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.
1313

Diff for: src/Examples/GettingStarted/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ For further documentation and implementation of a JsonApiDotNetCore Application
1111

1212
Repository: https://github.com/json-api-dotnet/JsonApiDotNetCore
1313

14-
Documentation: http://www.jsonapi.net
14+
Documentation: https://www.jsonapi.net

Diff for: test/TestBuildingBlocks/LogOutputFields.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ public enum LogOutputFields
88
{
99
None = 0,
1010
Level = 1,
11-
Category = 1 << 1,
12-
Message = 1 << 2,
13-
Exception = 1 << 3,
14-
Scopes = 1 << 4,
11+
CategoryName = 1 << 1,
12+
CategoryNamespace = 1 << 2,
13+
Message = 1 << 3,
14+
Exception = 1 << 4,
15+
Scopes = 1 << 5,
1516

17+
Category = CategoryName | CategoryNamespace,
1618
All = Level | Category | Message | Exception | Scopes
1719
}

Diff for: test/TestBuildingBlocks/XUnitLoggerProvider.cs

+32-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ namespace TestBuildingBlocks;
88
// Based on https://www.meziantou.net/how-to-get-asp-net-core-logs-in-the-output-of-xunit-tests.htm.
99
public sealed class XUnitLoggerProvider : ILoggerProvider
1010
{
11+
private const LogOutputFields DefaultLogOutputFields = LogOutputFields.All & ~LogOutputFields.CategoryNamespace;
1112
private readonly ITestOutputHelper _testOutputHelper;
1213
private readonly LogOutputFields _outputFields;
1314
private readonly string? _categoryPrefixFilter;
1415

15-
public XUnitLoggerProvider(ITestOutputHelper testOutputHelper, string? categoryPrefixFilter, LogOutputFields outputFields = LogOutputFields.All)
16+
public XUnitLoggerProvider(ITestOutputHelper testOutputHelper, string? categoryPrefixFilter, LogOutputFields outputFields = DefaultLogOutputFields)
1617
{
1718
ArgumentNullException.ThrowIfNull(testOutputHelper);
1819

@@ -41,7 +42,34 @@ private sealed class XUnitLogger(ITestOutputHelper testOutputHelper, LogOutputFi
4142
{
4243
private readonly ITestOutputHelper _testOutputHelper = testOutputHelper;
4344
private readonly LogOutputFields _outputFields = outputFields;
44-
private readonly string _categoryName = categoryName;
45+
private readonly string? _categoryText = GetCategoryText(categoryName, outputFields);
46+
47+
private static string? GetCategoryText(string categoryName, LogOutputFields outputFields)
48+
{
49+
if (outputFields.HasFlag(LogOutputFields.Category))
50+
{
51+
return categoryName;
52+
}
53+
54+
bool hasName = outputFields.HasFlag(LogOutputFields.CategoryName);
55+
bool hasNamespace = outputFields.HasFlag(LogOutputFields.CategoryNamespace);
56+
57+
if (hasName || hasNamespace)
58+
{
59+
// Microsoft.Extensions.Logging.LoggerFactory.CreateLogger(Type) removes generic type parameters
60+
// and replaces '+' (nested class) with '.'.
61+
int lastDotIndex = categoryName.LastIndexOf('.');
62+
63+
if (lastDotIndex == -1)
64+
{
65+
return hasName ? categoryName : string.Empty;
66+
}
67+
68+
return hasName ? categoryName[(lastDotIndex + 1)..] : categoryName[..lastDotIndex];
69+
}
70+
71+
return null;
72+
}
4573

4674
public bool IsEnabled(LogLevel logLevel)
4775
{
@@ -68,15 +96,15 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
6896
builder.Append(logLevelString);
6997
}
7098

71-
if (_outputFields.HasFlag(LogOutputFields.Category))
99+
if (_categoryText != null)
72100
{
73101
if (builder.Length > 0)
74102
{
75103
builder.Append(' ');
76104
}
77105

78106
builder.Append('[');
79-
builder.Append(_categoryName);
107+
builder.Append(_categoryText);
80108
builder.Append(']');
81109
}
82110

0 commit comments

Comments
 (0)