Skip to content
Open
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: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ dotnet_diagnostic.KR1037.severity = none
dotnet_diagnostic.NUnit2045.severity = none
# IDE0079: Remove unnecessary suppressions
dotnet_diagnostic.IDE0079.severity = none
# IDE0005: Remove unnecessary usings. Shown in the IDE only: enforcing it on build would also need
# EnforceCodeStyleInBuild and GenerateDocumentationFile, which the test projects do not set.
dotnet_diagnostic.IDE0005.severity = warning

[*.xml]
tab_width = 2
Expand Down
18 changes: 17 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,20 @@ jobs:

- name: Test
run: |
dotnet test ./src/log4net.sln
dotnet test ./src/log4net.sln

# Runs the same probes twice, JIT compiled and published with Native AOT, so that a
# difference between the two is caused by AOT rather than by the platform. The project
# knows which probes are expected to fail in each mode and exits non-zero when reality
# does not match, in either direction.
- name: AOT probes
shell: pwsh
env:
"log4net.AotEnvironmentProbe": from-environment
run: |
dotnet run --project ./src/log4net.Tests.Aot/log4net.Tests.Aot.csproj -c Release
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
dotnet publish ./src/log4net.Tests.Aot/log4net.Tests.Aot.csproj -c Release -o ./aot-probes
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
& "./aot-probes/log4net.Tests.Aot$($IsWindows ? '.exe' : '')"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,6 @@ validate
/graphify-out/.graphify_python
/graphify-out/*.sig
/graphify-out/20*

# output of the AOT probe step
/aot-probes/
8 changes: 8 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@
<AnalysisLevel>8</AnalysisLevel>
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
<RunAnalyzersDuringLiveAnalysis>true</RunAnalyzersDuringLiveAnalysis>
<!-- Reports code style rules such as IDE0005 (unnecessary usings) on build, not only in the
IDE. IDE0005 needs the documentation file, so that is switched on everywhere too. -->
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<_SkipUpgradeNetAnalyzersNuGetWarning>true</_SkipUpgradeNetAnalyzersNuGetWarning>
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
<SatelliteResourceLanguages>en;en-US</SatelliteResourceLanguages>
</PropertyGroup>
<PropertyGroup Condition="$(MSBuildProjectName.Contains('Tests')) or $(MSBuildProjectDirectory.Contains('integration-testing'))">
<!-- Only the shipping libraries have to document their public surface. -->
<NoWarn>$(NoWarn);CS1591</NoWarn>
</PropertyGroup>
<PropertyGroup Label="Package Versions">
<VersionPrefix>3.4.0</VersionPrefix>
<Log4NetPackageVersion>3.3.2</Log4NetPackageVersion>
Expand Down
14 changes: 14 additions & 0 deletions src/changelog/3.4.0/306-usable-from-a-publishaot-build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://logging.apache.org/xml/ns"
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
type="fixed">
<issue id="233" link="https://github.com/apache/logging-log4net/issues/233"/>
<issue id="306" link="https://github.com/apache/logging-log4net/pull/306"/>
<description format="asciidoc">Make log4net usable from a `PublishAot` build, where `LogManager.GetLogger()`
used to throw `PlatformNotSupportedException` from `Assembly.GetCallingAssembly()`, and where
repositories and pattern converters were left without a constructor by the trimmer. Configuration
has to be done in code - see the new
https://logging.apache.org/log4net/latest/manual/native-aot.html[Native AOT and trimming] page
(reported by @vpenades, implemented by @FreeAndNil in https://github.com/apache/logging-log4net/pull/306[#306])</description>
</entry>
1 change: 0 additions & 1 deletion src/integration-testing/log4net-611-lib/DerivedAppender.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Diagnostics;
using log4net.Appender;
using log4net.Core;

Expand Down
1 change: 0 additions & 1 deletion src/log4net.Ext.Mail.Tests/Appender/FakeSmtpTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
using System.Net;
using System.Text;

using log4net.Ext.Mail.Appender;
using log4net.Ext.Mail.Appender.Internal;

using MailKit.Security;
Expand Down
1 change: 0 additions & 1 deletion src/log4net.Ext.Mail.Tests/Appender/SmtpAppenderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
using System.Text;
using log4net.Core;
using log4net.Ext.Mail.Appender;
using log4net.Ext.Mail.Appender.Internal;
using log4net.Layout;
using MailKit.Security;
using MimeKit;
Expand Down
4 changes: 2 additions & 2 deletions src/log4net.Ext.Mail.Tests/log4net.Ext.Mail.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<IsTestProject>true</IsTestProject>
<TargetFrameworks>net10.0</TargetFrameworks>
<NoWarn>NETSDK1138;CS1701</NoWarn>
<NoWarn>$(NoWarn);NETSDK1138;CS1701</NoWarn>
<OutputType>Library</OutputType>
<OutputPath>bin\$(Configuration)</OutputPath>
<Configurations>Debug;Release</Configurations>
Expand All @@ -11,7 +11,7 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<DefineConstants>TRACE;DEBUG;$(DefineConstants)</DefineConstants>
<!-- suppress analyzer mismatch warning -->
<NoWarn>CS8032</NoWarn>
<NoWarn>$(NoWarn);CS8032</NoWarn>
<VSTestLogger>quackers</VSTestLogger>
</PropertyGroup>
<ItemGroup>
Expand Down
22 changes: 22 additions & 0 deletions src/log4net.Tests.Aot/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to you under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<configuration>
<appSettings>
<add key="log4net.AotProbe" value="from-config" />
</appSettings>
</configuration>
36 changes: 36 additions & 0 deletions src/log4net.Tests.Aot/Probe.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#region Apache License
//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to you under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#endregion

using System;

namespace log4net.Tests.Aot;

/// <summary>
/// One named piece of log4net surface to exercise.
/// </summary>
/// <param name="Area">the grouping the probe belongs to</param>
/// <param name="Name">what the probe exercises</param>
/// <param name="Run">the probe itself, which throws to signal failure</param>
internal sealed record Probe(string Area, string Name, Action Run)
{
/// <summary>
/// Identifies the probe in the expected failure lists.
/// </summary>
internal string Key => $"{Area}/{Name}";
}
Loading
Loading