Skip to content

Commit accfd5f

Browse files
committed
Add .NET 10 support and central package management
1 parent 2270370 commit accfd5f

13 files changed

Lines changed: 210 additions & 163 deletions

File tree

.github/workflows/dotnet.yml

Lines changed: 64 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ env:
55
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
66
DOTNET_ENVIRONMENT: github
77
ASPNETCORE_ENVIRONMENT: github
8-
BUILD_PATH: '${{github.workspace}}/artifacts'
8+
BUILD_PATH: "${{github.workspace}}/artifacts"
99
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
1010

1111
on:
@@ -14,97 +14,92 @@ on:
1414
- master
1515
- develop
1616
tags:
17-
- 'v*'
17+
- "v*"
1818
pull_request:
1919
branches:
2020
- master
2121
- develop
2222

2323
jobs:
24-
2524
build:
2625
runs-on: ubuntu-latest
2726

2827
services:
2928
mongodb:
3029
image: mongo:latest
3130
ports:
32-
- 27017:27017
31+
- 27017:27017
3332
volumes:
34-
- mongo_data:/data/db
35-
- mongo_config:/data/configdb
33+
- mongo_data:/data/db
34+
- mongo_config:/data/configdb
3635

3736
steps:
38-
- name: Checkout
39-
uses: actions/checkout@v6
40-
with:
41-
fetch-depth: 0
42-
43-
- name: Install .NET Core
44-
uses: actions/setup-dotnet@v5
45-
with:
46-
dotnet-version: |
47-
6.0.x
48-
7.0.x
49-
8.0.x
50-
51-
- name: Restore Dependencies
52-
run: dotnet restore
53-
54-
- name: Build Solution
55-
run: dotnet build --no-restore --configuration Release
56-
57-
- name: Run Test
58-
run: dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --settings coverlet.runsettings
59-
60-
- name: Report Coverage
61-
if: success()
62-
uses: coverallsapp/github-action@v2
63-
with:
64-
file: '${{github.workspace}}/test/*/TestResults/*/coverage.info'
37+
- name: Checkout
38+
uses: actions/checkout@v6
39+
with:
40+
fetch-depth: 0
41+
42+
- name: Install .NET Core
43+
uses: actions/setup-dotnet@v5
44+
with:
45+
dotnet-version: 10.x
46+
47+
- name: Restore Dependencies
48+
run: dotnet restore
49+
50+
- name: Build Solution
51+
run: dotnet build --no-restore --configuration Release
52+
53+
- name: Run Test
54+
run: dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --settings coverlet.runsettings
55+
56+
- name: Report Coverage
57+
if: success()
58+
uses: coverallsapp/github-action@v2
59+
with:
60+
file: "${{github.workspace}}/test/*/TestResults/*/coverage.info"
6561
format: lcov
6662

67-
- name: Create Packages
68-
if: success() && github.event_name != 'pull_request'
69-
run: dotnet pack --configuration Release --no-build --output "${{env.BUILD_PATH}}"
63+
- name: Create Packages
64+
if: success() && github.event_name != 'pull_request'
65+
run: dotnet pack --configuration Release --no-build --output "${{env.BUILD_PATH}}"
7066

71-
- name: Upload Packages
72-
if: success() && github.event_name != 'pull_request'
73-
uses: actions/upload-artifact@v6
74-
with:
75-
name: packages
76-
path: '${{env.BUILD_PATH}}'
67+
- name: Upload Packages
68+
if: success() && github.event_name != 'pull_request'
69+
uses: actions/upload-artifact@v6
70+
with:
71+
name: packages
72+
path: "${{env.BUILD_PATH}}"
7773

7874
deploy:
7975
runs-on: ubuntu-latest
8076
needs: build
8177
if: success() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v'))
8278

8379
steps:
84-
- name: Download Artifact
85-
uses: actions/download-artifact@v7
86-
with:
87-
name: packages
88-
89-
- name: Publish Packages GitHub
90-
run: |
91-
for package in $(find -name "*.nupkg"); do
92-
echo "${0##*/}": Pushing $package...
93-
dotnet nuget push $package --source https://nuget.pkg.github.com/loresoft/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
94-
done
95-
96-
- name: Publish Packages feedz
97-
run: |
98-
for package in $(find -name "*.nupkg"); do
99-
echo "${0##*/}": Pushing $package...
100-
dotnet nuget push $package --source https://f.feedz.io/loresoft/open/nuget/index.json --api-key ${{ secrets.FEEDDZ_KEY }} --skip-duplicate
101-
done
102-
103-
- name: Publish Packages Nuget
104-
if: startsWith(github.ref, 'refs/tags/v')
105-
run: |
106-
for package in $(find -name "*.nupkg"); do
107-
echo "${0##*/}": Pushing $package...
108-
dotnet nuget push $package --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }} --skip-duplicate
109-
done
110-
80+
- name: Download Artifact
81+
uses: actions/download-artifact@v7
82+
with:
83+
name: packages
84+
85+
- name: Publish Packages GitHub
86+
run: |
87+
for package in $(find -name "*.nupkg"); do
88+
echo "${0##*/}": Pushing $package...
89+
dotnet nuget push $package --source https://nuget.pkg.github.com/loresoft/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
90+
done
91+
92+
- name: Publish Packages feedz
93+
run: |
94+
for package in $(find -name "*.nupkg"); do
95+
echo "${0##*/}": Pushing $package...
96+
dotnet nuget push $package --source https://f.feedz.io/loresoft/open/nuget/index.json --api-key ${{ secrets.FEEDDZ_KEY }} --skip-duplicate
97+
done
98+
99+
- name: Publish Packages Nuget
100+
if: startsWith(github.ref, 'refs/tags/v')
101+
run: |
102+
for package in $(find -name "*.nupkg"); do
103+
echo "${0##*/}": Pushing $package...
104+
dotnet nuget push $package --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }} --skip-duplicate
105+
done

.github/workflows/stale.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Stale Items
2+
on:
3+
schedule:
4+
- cron: "0 6 * * 0"
5+
6+
workflow_dispatch:
7+
8+
jobs:
9+
stale:
10+
name: Mark and Close Stale Items
11+
runs-on: ubuntu-latest
12+
permissions:
13+
issues: write
14+
pull-requests: write
15+
steps:
16+
- uses: actions/stale@v10
17+
with:
18+
repo-token: ${{ secrets.GITHUB_TOKEN }}
19+
20+
days-before-stale: 365
21+
days-before-close: 45
22+
23+
# Issue configuration
24+
stale-issue-label: "stale"
25+
close-issue-label: "closed:stale"
26+
exempt-issue-labels: "pinned,security,enhancement,bug,backlog,epic"
27+
28+
stale-issue-message: |
29+
## ⏰ Stale Issue
30+
31+
This issue has had no activity for 1 year.
32+
It will be closed in 45 days unless there is new activity.
33+
To keep it open, comment or remove the `stale` label.
34+
35+
close-issue-message: |
36+
## 🔒 Closed: Inactive Issue
37+
38+
Closed after 45 days of inactivity.
39+
To reopen, comment with a reason and a maintainer will review.
40+
41+
# PR configuration
42+
stale-pr-label: "stale"
43+
close-pr-label: "closed:stale"
44+
exempt-pr-labels: "pinned,work-in-progress,ready-for-review"
45+
46+
stale-pr-message: |
47+
## ⏰ Stale Pull Request
48+
49+
No activity for 1 year. Will close in 45 days unless updated.
50+
To keep open, push commits, comment, or remove the `stale` label.
51+
52+
close-pr-message: |
53+
## 🔒 Closed: Inactive PR
54+
55+
Closed after 45 days of inactivity.
56+
To continue, reopen or submit a new PR and reference this one.

Directory.Packages.props

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project>
2+
<PropertyGroup>
3+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4+
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<PackageVersion Include="AwesomeAssertions" Version="9.3.0" />
8+
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
9+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
10+
<PackageVersion Include="MinVer" Version="7.0.0" />
11+
<PackageVersion Include="MongoDB.Driver" Version="3.6.0" />
12+
<PackageVersion Include="NLog" Version="6.0.7" />
13+
<PackageVersion Include="Scrutor" Version="7.0.0" />
14+
<PackageVersion Include="XUnit.Hosting" Version="4.0.0" />
15+
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
16+
<PackageVersion Include="xunit.v3" Version="3.2.2" />
17+
</ItemGroup>
18+
</Project>

NLog.Mongo.sln

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
2-
# Visual Studio Version 17
3-
VisualStudioVersion = 17.6.33829.357
2+
# Visual Studio Version 18
3+
VisualStudioVersion = 18.2.11408.102 d18.0
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NLog.Mongo", "src\NLog.Mongo\NLog.Mongo.csproj", "{97D08F95-F710-4AF1-A49D-D2CFF770E764}"
66
EndProject
@@ -10,6 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{061EE777
1010
ProjectSection(SolutionItems) = preProject
1111
coverlet.runsettings = coverlet.runsettings
1212
src\Directory.Build.props = src\Directory.Build.props
13+
Directory.Packages.props = Directory.Packages.props
1314
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
1415
README.md = README.md
1516
EndProjectSection

src/Directory.Build.props

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

4040
<ItemGroup>
41-
<PackageReference Include="MinVer" Version="5.0.0" PrivateAssets="All" />
41+
<PackageReference Include="MinVer" PrivateAssets="All" />
4242
</ItemGroup>
4343

4444
<ItemGroup>

src/NLog.Mongo/IsExternalInit.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#if NETFRAMEWORK || NETSTANDARD2_1
2+
using System.ComponentModel;
3+
4+
#pragma warning disable IDE0130 // Namespace does not match folder structure
5+
namespace System.Runtime.CompilerServices;
6+
7+
/// <summary>
8+
/// Reserved to be used by the compiler for tracking metadata.
9+
/// This class should not be used by developers in source code.
10+
/// </summary>
11+
[EditorBrowsable(EditorBrowsableState.Never)]
12+
internal static class IsExternalInit
13+
{
14+
}
15+
#endif

src/NLog.Mongo/MongoTarget.cs

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,9 @@ namespace NLog.Mongo;
1919
[Target("Mongo")]
2020
public class MongoTarget : Target
2121
{
22-
private struct MongoConnectionKey : IEquatable<MongoConnectionKey>
23-
{
24-
private readonly string ConnectionString;
25-
private readonly string CollectionName;
26-
private readonly string DatabaseName;
27-
28-
public MongoConnectionKey(string connectionString, string collectionName, string databaseName)
29-
{
30-
ConnectionString = connectionString ?? string.Empty;
31-
CollectionName = collectionName ?? string.Empty;
32-
DatabaseName = databaseName ?? string.Empty;
33-
}
34-
35-
public bool Equals(MongoConnectionKey other)
36-
{
37-
return ConnectionString == other.ConnectionString
38-
&& CollectionName == other.CollectionName
39-
&& DatabaseName == other.DatabaseName;
40-
}
41-
42-
public override int GetHashCode()
43-
{
44-
return ConnectionString.GetHashCode() ^ CollectionName.GetHashCode() ^ DatabaseName.GetHashCode();
45-
}
46-
47-
public override bool Equals(object obj)
48-
{
49-
return obj is MongoConnectionKey && Equals((MongoConnectionKey)obj);
50-
}
51-
}
22+
private readonly record struct MongoConnectionKey(string ConnectionString, string CollectionName, string DatabaseName);
5223

53-
private static readonly ConcurrentDictionary<MongoConnectionKey, IMongoCollection<BsonDocument>> _collectionCache = new ConcurrentDictionary<MongoConnectionKey, IMongoCollection<BsonDocument>>();
24+
private static readonly ConcurrentDictionary<MongoConnectionKey, IMongoCollection<BsonDocument>> _collectionCache = new();
5425
private Func<AsyncLogEventInfo, BsonDocument> _createDocumentDelegate;
5526
private static readonly LogEventInfo _defaultLogEvent = NLog.LogEventInfo.CreateNullEvent();
5627

@@ -72,7 +43,7 @@ public MongoTarget()
7243
/// The fields.
7344
/// </value>
7445
[ArrayParameter(typeof(MongoField), "field")]
75-
public IList<MongoField> Fields { get; private set; }
46+
public IList<MongoField> Fields { get; }
7647

7748
/// <summary>
7849
/// Gets the properties collection.
@@ -81,7 +52,7 @@ public MongoTarget()
8152
/// The properties.
8253
/// </value>
8354
[ArrayParameter(typeof(MongoField), "property")]
84-
public IList<MongoField> Properties { get; private set; }
55+
public IList<MongoField> Properties { get; }
8556

8657
/// <summary>
8758
/// Gets or sets the connection string name string.

src/NLog.Mongo/NLog.Mongo.csproj

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net472;netstandard2.1;net6.0</TargetFrameworks>
3+
<TargetFrameworks>net472;netstandard2.1;net6.0;net8.0;net10.0</TargetFrameworks>
44
</PropertyGroup>
55

66
<ItemGroup>
7-
<PackageReference Include="MongoDB.Driver" Version="3.1.0" />
8-
<PackageReference Include="NLog" Version="5.3.4" />
9-
</ItemGroup>
10-
11-
<ItemGroup>
12-
<PackageReference Update="MinVer" Version="6.0.0" />
7+
<PackageReference Include="MongoDB.Driver" />
8+
<PackageReference Include="NLog" />
139
</ItemGroup>
1410

1511
</Project>

test/NLog.Mongo.ConsoleTest/NLog.Mongo.ConsoleTest.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<OutputType>Exe</OutputType>
66
<IsPackable>false</IsPackable>
77
</PropertyGroup>

0 commit comments

Comments
 (0)