Skip to content

Commit c73f2f5

Browse files
Merge branch 'main' into dotnet-vnext
2 parents 622f4fe + 5bb45ae commit c73f2f5

14 files changed

+74
-149
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
shell: pwsh
6868
run: ./build.ps1
6969

70-
- uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 # v5.3.1
70+
- uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5.4.0
7171
name: Upload coverage to Codecov
7272
with:
7373
flags: ${{ matrix.os-name }}
@@ -82,7 +82,7 @@ jobs:
8282
upload-release-assets: ${{ runner.os == 'Windows' }}
8383

8484
- name: Attest artifacts
85-
uses: actions/attest-build-provenance@520d128f165991a6c774bcb264f323e3d70747f4 # v2.2.0
85+
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
8686
if: |
8787
runner.os == 'Windows' &&
8888
github.event.repository.fork == false &&
@@ -118,7 +118,7 @@ jobs:
118118
steps:
119119

120120
- name: Download packages
121-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
121+
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
122122
with:
123123
name: packages-windows
124124

@@ -161,7 +161,7 @@ jobs:
161161
steps:
162162

163163
- name: Download packages
164-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
164+
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
165165
with:
166166
name: packages-windows
167167

@@ -191,7 +191,7 @@ jobs:
191191
steps:
192192

193193
- name: Download packages
194-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
194+
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
195195
with:
196196
name: packages-windows
197197

.github/workflows/bump-version.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,24 @@ jobs:
4040
4141
$xml = [xml](Get-Content $properties)
4242
$versionPrefix = $xml.SelectSingleNode('Project/PropertyGroup/VersionPrefix')
43+
$publishedVersion = $versionPrefix.InnerText
4344
4445
if (-Not [string]::IsNullOrEmpty(${env:NEXT_VERSION})) {
4546
$version = [System.Version]::new(${env:NEXT_VERSION})
4647
$assemblyVersionProperty = $xml.SelectSingleNode('Project/PropertyGroup/AssemblyVersion')
4748
$assemblyVersion = [System.Version]::new($version.Major, ($version.Major -eq 0 ? $version.Minor : 0), 0, 0)
4849
$assemblyVersionProperty.InnerText = $assemblyVersion.ToString()
4950
} else {
50-
$version = [System.Version]::new($versionPrefix.InnerText)
51+
$version = [System.Version]::new($publishedVersion)
5152
$version = [System.Version]::new($version.Major, $version.Minor, $version.Build + 1)
5253
}
5354
5455
$updatedVersion = $version.ToString()
5556
$versionPrefix.InnerText = $updatedVersion
5657
58+
$packageValidationBaselineVersion = $xml.SelectSingleNode('Project/PropertyGroup/PackageValidationBaselineVersion')
59+
$packageValidationBaselineVersion.InnerText = $publishedVersion
60+
5761
$settings = New-Object System.Xml.XmlWriterSettings
5862
$settings.Encoding = New-Object System.Text.UTF8Encoding($false)
5963
$settings.Indent = $true

.github/workflows/code-scan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ jobs:
3232
show-progress: false
3333

3434
- name: Initialize CodeQL
35-
uses: github/codeql-action/init@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10
35+
uses: github/codeql-action/init@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3.28.11
3636
with:
3737
build-mode: none
3838
languages: 'csharp'
3939
queries: security-and-quality
4040

4141
- name: Perform CodeQL Analysis
42-
uses: github/codeql-action/analyze@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10
42+
uses: github/codeql-action/analyze@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3.28.11
4343
with:
4444
category: "/language:csharp"

.github/workflows/ossf-scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ jobs:
4242
retention-days: 5
4343

4444
- name: Upload to code-scanning
45-
uses: github/codeql-action/upload-sarif@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10
45+
uses: github/codeql-action/upload-sarif@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3.28.11
4646
with:
4747
sarif_file: results.sarif

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ bin
1313
Bin
1414
coverage
1515
coverage.*
16+
MSBuild_Logs/
1617
obj
1718
packages
1819
TestResults

Directory.Build.props

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,34 @@
11
<Project>
22
<ItemGroup>
3-
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
43
<AssemblyAttribute Include="System.CLSCompliant">
54
<_Parameter1>false</_Parameter1>
65
<_Parameter1_IsLiteral>true</_Parameter1_IsLiteral>
76
</AssemblyAttribute>
87
</ItemGroup>
98
<PropertyGroup>
10-
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
11-
<AnalysisMode>All</AnalysisMode>
129
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)Logging.XUnit.snk</AssemblyOriginatorKeyFile>
13-
<Authors>martin_costello</Authors>
14-
<ChecksumAlgorithm>SHA256</ChecksumAlgorithm>
1510
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)Logging.XUnit.ruleset</CodeAnalysisRuleSet>
16-
<Company>https://github.com/martincostello/xunit-logging</Company>
17-
<ContinuousIntegrationBuild Condition=" '$(CI)' != '' ">true</ContinuousIntegrationBuild>
18-
<Copyright>Martin Costello (c) $([System.DateTime]::Now.ToString(yyyy))</Copyright>
19-
<Deterministic>true</Deterministic>
20-
<EmbedUntrackedSources>true</EmbedUntrackedSources>
21-
<EnableNETAnalyzers>true</EnableNETAnalyzers>
22-
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
23-
<GenerateDocumentationFile>false</GenerateDocumentationFile>
24-
<GenerateGitMetadata Condition=" '$(CI)' != '' AND '$(GenerateGitMetadata)' == '' ">true</GenerateGitMetadata>
25-
<ImplicitUsings>enable</ImplicitUsings>
26-
<LangVersion>latest</LangVersion>
2711
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
28-
<NeutralLanguage>en-US</NeutralLanguage>
2912
<!-- TODO Remove once .NET 10 is stable -->
3013
<NoWarn>$(NoWarn);NU5104</NoWarn>
3114
<NuGetAuditMode>direct</NuGetAuditMode>
32-
<Nullable>enable</Nullable>
33-
<PackageIcon>package-icon.png</PackageIcon>
34-
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
35-
<PackageProjectUrl>https://github.com/martincostello/xunit-logging</PackageProjectUrl>
36-
<PackageReadmeFile>package-readme.md</PackageReadmeFile>
37-
<PackageReleaseNotes>See $(PackageProjectUrl)/releases for details.</PackageReleaseNotes>
38-
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
3915
<PackageTags>xunit;logging</PackageTags>
40-
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
41-
<PublishRepositoryUrl>true</PublishRepositoryUrl>
42-
<RepositoryType>git</RepositoryType>
43-
<RepositoryUrl>$(PackageProjectUrl).git</RepositoryUrl>
44-
<SignAssembly>true</SignAssembly>
45-
<StrongNamePublicKey Condition=" '$(SignAssembly)' == 'true'">00240000048000009400000006020000002400005253413100040000010001004b0b2efbada897147aa03d2076278890aefe2f8023562336d206ec8a719b06e89461c31b43abec615918d509158629f93385930c030494509e418bf396d69ce7dbe0b5b2db1a81543ab42777cb98210677fed69dbeb3237492a7ad69e87a1911ed20eb2d7c300238dc6f6403e3d04a1351c5cb369de4e022b18fbec70f7d21ed</StrongNamePublicKey>
46-
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
47-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
4816
<UseArtifactsOutput>true</UseArtifactsOutput>
4917
<AssemblyVersion>0.5.0.0</AssemblyVersion>
18+
<PackageValidationBaselineVersion>0.5.0</PackageValidationBaselineVersion>
5019
<VersionPrefix>0.5.2</VersionPrefix>
5120
</PropertyGroup>
52-
<PropertyGroup Condition=" '$(GITHUB_ACTIONS)' != '' AND '$(DEPENDABOT_JOB_ID)' == '' ">
53-
<VersionSuffix Condition=" '$(VersionSuffix)' == '' AND '$(GITHUB_HEAD_REF)' == '' ">beta.$(GITHUB_RUN_NUMBER)</VersionSuffix>
54-
<VersionSuffix Condition=" '$(VersionSuffix)' == '' AND '$(GITHUB_HEAD_REF)' != '' ">pr.$(GITHUB_REF_NAME.Replace('/merge', '')).$(GITHUB_RUN_NUMBER)</VersionSuffix>
55-
<VersionPrefix Condition=" $(GITHUB_REF.StartsWith(`refs/tags/v`)) ">$(GITHUB_REF.Replace('refs/tags/v', ''))</VersionPrefix>
56-
<VersionSuffix Condition=" $(GITHUB_REF.StartsWith(`refs/tags/v`)) "></VersionSuffix>
57-
<FileVersion Condition=" '$(GITHUB_RUN_NUMBER)' != '' ">$(VersionPrefix).$(GITHUB_RUN_NUMBER)</FileVersion>
58-
</PropertyGroup>
5921
<PropertyGroup Condition=" '$(EnableReferenceTrimmer)' != 'false' and '$(GenerateDocumentationFile)' != 'true' ">
6022
<GenerateDocumentationFile>true</GenerateDocumentationFile>
6123
<NoWarn>$(NoWarn);419;1570;1573;1574;1584;1591;SA0001;SA1602</NoWarn>
6224
</PropertyGroup>
63-
<ItemGroup Condition=" '$(PackageIcon)' != '' ">
64-
<None Include="$(MSBuildThisFileDirectory)$(PackageIcon)" Pack="True" PackagePath="" />
65-
</ItemGroup>
66-
<ItemGroup Condition=" '$(PackageReadmeFile)' != '' ">
67-
<None Include="$(MSBuildThisFileDirectory)$(PackageReadmeFile)" Pack="True" PackagePath="" />
68-
</ItemGroup>
6925
<PropertyGroup Condition=" '$(BuildingInsideVisualStudio)' != 'true' ">
7026
<CollectCoverage>true</CollectCoverage>
7127
<CoverletOutputFormat>cobertura,json</CoverletOutputFormat>
7228
<Exclude>[SampleApp]*,[xunit.*]*</Exclude>
7329
<Threshold>93</Threshold>
7430
</PropertyGroup>
7531
<ItemGroup>
76-
<Using Include="System.Globalization" />
7732
<Using Include="Xunit" />
7833
<Using Include="Xunit.Sdk" />
7934
</ItemGroup>
@@ -83,7 +38,4 @@
8338
<ItemGroup Condition=" !$(DefineConstants.Contains('XUNIT_V3')) ">
8439
<Using Include="Xunit.Abstractions" />
8540
</ItemGroup>
86-
<ItemGroup Condition=" '$(IsTestProject)' == 'true' ">
87-
<Using Include="Shouldly" />
88-
</ItemGroup>
8941
</Project>

Directory.Build.targets

Lines changed: 0 additions & 62 deletions
This file was deleted.

Directory.Packages.props

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project>
22
<ItemGroup>
3-
<GlobalPackageReference Include="ReferenceTrimmer" Version="3.3.10" PrivateAssets="All" />
3+
<GlobalPackageReference Include="MartinCostello.BuildKit" Version="0.1.0" />
4+
<GlobalPackageReference Include="ReferenceTrimmer" Version="3.3.11" PrivateAssets="All" />
45
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" PrivateAssets="All" />
56
</ItemGroup>
67
<ItemGroup>
@@ -16,12 +17,7 @@
1617
<PackageVersion Include="xunit.abstractions" Version="2.0.3" />
1718
<PackageVersion Include="xunit.extensibility.execution" Version="2.4.1" />
1819
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2" />
19-
<PackageVersion Include="xunit.v3" Version="1.1.0" />
20-
<PackageVersion Include="xunit.v3.extensibility.core" Version="1.1.0" />
21-
</ItemGroup>
22-
<ItemGroup Condition=" '$(IsTestProject)' == 'true' ">
23-
<PackageReference Include="coverlet.msbuild" PrivateAssets="All" />
24-
<PackageReference Include="GitHubActionsTestLogger" PrivateAssets="All" NoWarn="RT0003" />
25-
<PackageReference Include="ReportGenerator" PrivateAssets="All" />
20+
<PackageVersion Include="xunit.v3" Version="2.0.0" />
21+
<PackageVersion Include="xunit.v3.extensibility.core" Version="2.0.0" />
2622
</ItemGroup>
2723
</Project>

Logging.XUnit.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1111
build.ps1 = build.ps1
1212
CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md
1313
Directory.Build.props = Directory.Build.props
14-
Directory.Build.targets = Directory.Build.targets
1514
Directory.Packages.props = Directory.Packages.props
1615
global.json = global.json
1716
LICENSE = LICENSE

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ dotnet add package MartinCostello.Logging.XUnit.v3
3939

4040
### Usage
4141

42+
#### Dependency Injection
43+
4244
```csharp
4345
using Microsoft.Extensions.DependencyInjection;
4446
using Microsoft.Extensions.Logging;
@@ -81,6 +83,51 @@ public sealed class Calculator(ILogger<Calculator> logger)
8183
}
8284
```
8385

86+
#### Standalone Logging Components
87+
88+
```csharp
89+
using Microsoft.Extensions.DependencyInjection;
90+
using Microsoft.Extensions.Logging;
91+
using Xunit;
92+
using Xunit.Abstractions; // For xunit v2 - not required for xunit v3
93+
94+
namespace MyApp.Calculator;
95+
96+
public class CalculatorTests(ITestOutputHelper outputHelper)
97+
{
98+
[Fact]
99+
public void Calculator_Sums_Two_Integers()
100+
{
101+
// Arrange
102+
var loggerFactory = LoggerFactory.Create(builder => builder
103+
.AddProvider(new XUnitLoggerProvider(outputHelper, xunitLoggerOptions))
104+
.SetMinimumLevel(LogLevel.Trace));
105+
106+
var logger = loggerFactory.CreateLogger<Calculator>();
107+
108+
var calculator = new Calculator(logger);
109+
110+
// Act
111+
int actual = calculator.Sum(1, 2);
112+
113+
// Assert
114+
Assert.AreEqual(3, actual);
115+
}
116+
}
117+
118+
public sealed class Calculator(ILogger<Calculator> logger)
119+
{
120+
public int Sum(int x, int y)
121+
{
122+
int sum = x + y;
123+
124+
logger.LogInformation("The sum of {x} and {y} is {sum}.", x, y, sum);
125+
126+
return sum;
127+
}
128+
}
129+
```
130+
84131
See below for links to more examples:
85132

86133
- [Unit tests][example-unit-tests]

0 commit comments

Comments
 (0)