Skip to content

Merge master into openapi #1707

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

Merged
merged 4 commits into from
Mar 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -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.*
Expand Down Expand Up @@ -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.*
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion PackageReadme.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<a href="https://www.jsonapi.net"><img src="docs/home/assets/img/logo.svg" style="height: 345px; width: 345px"/></a>

# 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.

Expand Down
2 changes: 1 addition & 1 deletion src/Examples/GettingStarted/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 6 additions & 4 deletions test/TestBuildingBlocks/LogOutputFields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
36 changes: 32 additions & 4 deletions test/TestBuildingBlocks/XUnitLoggerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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)
{
Expand All @@ -68,15 +96,15 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
builder.Append(logLevelString);
}

if (_outputFields.HasFlag(LogOutputFields.Category))
if (_categoryText != null)
{
if (builder.Length > 0)
{
builder.Append(' ');
}

builder.Append('[');
builder.Append(_categoryName);
builder.Append(_categoryText);
builder.Append(']');
}

Expand Down
Loading