Skip to content
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

dropping legacy serialization support #174

Merged
Show file tree
Hide file tree
Changes from 18 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
51 changes: 51 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
# 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.
#

name: build

on:
workflow_dispatch:

jobs:

build:

runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]

steps:

- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7

- name: Set up dotnet
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # 4.0.1
with:
dotnet-version: 8
dotnet-quality: ga

- name: Build
Copy link
Contributor

@fluffynuts fluffynuts Sep 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest: if you set up Node, you can do npm test to do all the build and test stuff you need via zarro. This way isn't wrong or anything, zarro is just more convenient, and will use the Quackers logger, which produces a useful final summary including failures and slow tests (and which works without zarro, but because of bugs in the dotnet test logger, you'll see some things twice - I've raised the issue so long ago that it's now been close because someone has started on a new logging framework for dotnet test, apparently).

For instance, we do something like this on our builds:

    - name: ⚙️ Setup .NET
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: ${{ matrix.dotnet-version }}

    - name: 🐢 Setup NodeJs
      uses: actions/setup-node@v4
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'npm'

    - name: 🏗️ Build and test 🧪
      env:
        DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
        DOTNET_CLI_TELEMETRY_OPTOUT: 1
      run: |
        npm update -g npm --no-progress
        npm install --no-progress
        npm test

which runs all the tests with pretty, fully-namespaced output, and produces a summary like this:
image

as well as the list of slow tests and their timings above. What's considered slow? Default is any test taking more than 1s, but that can be guided by Quackers config (see: https://github.com/fluffynuts/quackers )

yes, quackers and zarro are more of my nonsense, so it's up to you. They are both currently installed - but I'd suggest updating them to latest

  • npm install --save-dev zarro@latest
  • either upgrade Quackers.TestLogger via your preferred mechanism or use zarro, with the environment variable UPGRADE_PACKAGES (which can accept regex values) and zarro upgrade-packages. I can help with this if you like. Although it's a little slow (waiting on nuget.org a lot), it's hella convenient, and how I keep several of our more volatile packages up to date in our work projects.

If you decide to keep on using zarro and need any assistance, please shout.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fluffynuts,

Feel free to modify the GitHub action. The current version is rather my attempt to understand how to build the project.

run: |
dotnet restore src/log4net.sln
dotnet build src/log4net.sln

- name: Test
run: dotnet test src/log4net.sln
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ ENV PATH="$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools"

ADD . /logging-log4net
RUN dotnet restore /logging-log4net/src/log4net.sln
RUN dotnet build /logging-log4net/src/log4net.sln
CMD /bin/bash
RUN dotnet build -c Release /logging-log4net/src/log4net.sln
CMD ["/bin/bash"]
2 changes: 1 addition & 1 deletion doc/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ release version 2.0.123:
- log4net.build: update package.version property
- pom.xml: update version
4. Sign release artifacts (zips & nupkg) under `build/artifacts`
- eg `gpg --argmor --output log4net-2.0.123.nupkg.asc --detach-sig log4net-2.0.123.nupkg`
- eg `gpg --armor --output log4net-2.0.123.nupkg.asc --detach-sig log4net-2.0.123.nupkg`
- there is an accompanying `sign-log4net-libraries.sh` which you could invoke if you cd
into the `build/artifacts` folder
- I build on Windows and sign on Linux as my build machine belongs to my company
Expand Down
22 changes: 3 additions & 19 deletions log4net.snk.readme
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,11 @@ Apache log4net Strong Name Key Readme
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The log4net release builds are strongly named using the log4net.snk key
file. This key is different from the key used to sign log4net 1.2.10
and earlier releases.

Starting with log4net 1.2.11 we've decided to use a key that we don't
file. Starting with log4net 1.2.11 we've decided to use a key that we don't
keep secret so you can build a drop-in replacement for an official
release yourself. This means that the strong name of a log4net
release yourself. This means that the strong name of a log4net
assembly no longer provides any means of checking its authenticity.
The only way to ensure you are using an official release by the Apache
Software Foundation is by downloading the distribution from the Apache
log4net download page and verifying the PGP signature of the ZIP
archive.

The key used to sign those older releases is not and has never been
distributed as part of the log4net source or binary downloads.

In order to make it easier to migrate from log4net 1.2.10 to newer
releases log4net 1.2.11 we also provide builds using the key used to
sign 1.2.10. We may stop distributing these alternative builds in the
future.

You should use the binary builds signed with log4net.snk for new
projects and only use the ones signed with "the old key" if switching
to the newer builds is not possible because other parts of your
project depend on the old strong name.
archive.
8 changes: 0 additions & 8 deletions src/MonoForFramework.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/usr/lib/mono')">/usr/lib/mono</BaseFrameworkPathOverrideForMono>
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/usr/local/lib/mono')">/usr/local/lib/mono</BaseFrameworkPathOverrideForMono>
<!-- If we found Mono reference assemblies, then use them -->
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net20'">$(BaseFrameworkPathOverrideForMono)/2.0-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net35'">$(BaseFrameworkPathOverrideForMono)/3.5-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net40'">$(BaseFrameworkPathOverrideForMono)/4.0-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net45'">$(BaseFrameworkPathOverrideForMono)/4.5-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net451'">$(BaseFrameworkPathOverrideForMono)/4.5.1-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net452'">$(BaseFrameworkPathOverrideForMono)/4.5.2-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net46'">$(BaseFrameworkPathOverrideForMono)/4.6-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net461'">$(BaseFrameworkPathOverrideForMono)/4.6.1-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net462'">$(BaseFrameworkPathOverrideForMono)/4.6.2-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net47'">$(BaseFrameworkPathOverrideForMono)/4.7-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net471'">$(BaseFrameworkPathOverrideForMono)/4.7.1-api</FrameworkPathOverride>
Expand Down
2 changes: 1 addition & 1 deletion src/build-preview.ps1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dotnet build -c Release '-p:GeneratePackages=true;VersionSuffix=preview.2' ./log4net/log4net.csproj
dotnet build -c Release '-p:GeneratePackages=true;VersionSuffix=preview.4' ./log4net/log4net.csproj
28 changes: 0 additions & 28 deletions src/changes/changes.xml

This file was deleted.

12 changes: 11 additions & 1 deletion src/log4net.Tests/Appender/RollingFileAppenderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,7 @@ private static void AssertFileEquals(string filename, string contents)
[Test]
public void TestLogOutput()
{
Utils.InconclusiveOnMono();
string filename = "test_simple.log";
SilentErrorHandler sh = new();
ILogger log = CreateLogger(filename, new FileAppender.ExclusiveLock(), sh);
Expand Down Expand Up @@ -1419,6 +1420,7 @@ public void TestExclusiveLockFails()
[Test]
public void TestExclusiveLockRecovers()
{
Utils.InconclusiveOnMono();
string filename = "test_exclusive_lock_recovers.log";

FileStream fs = new(filename, FileMode.Create, FileAccess.Write, FileShare.None);
Expand All @@ -1442,6 +1444,7 @@ public void TestExclusiveLockRecovers()
[Test]
public void TestExclusiveLockLocks()
{
Utils.InconclusiveOnMono();
string filename = "test_exclusive_lock_locks.log";
bool locked = false;

Expand All @@ -1458,7 +1461,7 @@ public void TestExclusiveLockLocks()
catch (IOException e1)
{
Assert.AreEqual("The process cannot access the file ", e1.Message.Substring(0, 35),
"Unexpected exception");
"Unexpected exception");
locked = true;
}

Expand All @@ -1478,6 +1481,7 @@ public void TestExclusiveLockLocks()
[Test]
public void TestMinimalLockFails()
{
Utils.InconclusiveOnMono();
string filename = "test_minimal_lock_fails.log";

FileStream fs = new(filename, FileMode.Create, FileAccess.Write, FileShare.None);
Expand All @@ -1501,6 +1505,7 @@ public void TestMinimalLockFails()
[Test]
public void TestMinimalLockRecovers()
{
Utils.InconclusiveOnMono();
string filename = "test_minimal_lock_recovers.log";

FileStream fs = new(filename, FileMode.Create, FileAccess.Write, FileShare.None);
Expand All @@ -1524,6 +1529,7 @@ public void TestMinimalLockRecovers()
[Test]
public void TestMinimalLockUnlocks()
{
Utils.InconclusiveOnMono();
string filename = "test_minimal_lock_unlocks.log";
bool locked;

Expand Down Expand Up @@ -1552,6 +1558,7 @@ public void TestMinimalLockUnlocks()
[Test]
public void TestInterProcessLockFails()
{
Utils.InconclusiveOnMono();
string filename = "test_interprocess_lock_fails.log";

FileStream fs = new(filename, FileMode.Create, FileAccess.Write, FileShare.None);
Expand All @@ -1575,6 +1582,7 @@ public void TestInterProcessLockFails()
[Test]
public void TestInterProcessLockRecovers()
{
Utils.InconclusiveOnMono();
string filename = "test_interprocess_lock_recovers.log";

FileStream fs = new(filename, FileMode.Create, FileAccess.Write, FileShare.None);
Expand All @@ -1598,6 +1606,7 @@ public void TestInterProcessLockRecovers()
[Test]
public void TestInterProcessLockUnlocks()
{
Utils.InconclusiveOnMono();
string filename = "test_interprocess_lock_unlocks.log";
bool locked;

Expand Down Expand Up @@ -1626,6 +1635,7 @@ public void TestInterProcessLockUnlocks()
[Test]
public void TestInterProcessLockRoll()
{
Utils.InconclusiveOnMono();
const string filename = "test_interprocess_lock_roll.log";

SilentErrorHandler sh = new();
Expand Down
3 changes: 3 additions & 0 deletions src/log4net.Tests/Appender/SmtpPickupDirAppenderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ private static void DestroyLogger()
[Test]
public void TestOutputContainsSentDate()
{
Utils.InconclusiveOnMono();
SilentErrorHandler sh = new SilentErrorHandler();
SmtpPickupDirAppender appender = CreateSmtpPickupDirAppender(sh);
ILogger log = CreateLogger(appender);
Expand Down Expand Up @@ -203,6 +204,7 @@ public void TestOutputContainsSentDate()
[Test]
public void TestConfigurableFileExtension()
{
Utils.InconclusiveOnMono();
const string fileExtension = "eml";
SilentErrorHandler sh = new SilentErrorHandler();
SmtpPickupDirAppender appender = CreateSmtpPickupDirAppender(sh);
Expand All @@ -226,6 +228,7 @@ public void TestConfigurableFileExtension()
[Test]
public void TestDefaultFileNameIsAGuid()
{
Utils.InconclusiveOnMono();
SilentErrorHandler sh = new SilentErrorHandler();
SmtpPickupDirAppender appender = CreateSmtpPickupDirAppender(sh);
ILogger log = CreateLogger(appender);
Expand Down
2 changes: 2 additions & 0 deletions src/log4net.Tests/Core/LoggingEventTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private static readonly DateTime localTime
[Test]
public void SerializeDeserialize_BinaryFormatter()
{
Utils.InconclusiveOnMono();
var timestamp = localTime.ToUniversalTime();
var ev = new LoggingEvent(new LoggingEventData
{
Expand Down Expand Up @@ -87,6 +88,7 @@ public void SerializeDeserialize_BinaryFormatter()
[Test]
public void DeserializeV2()
{
Utils.InconclusiveOnMono();
const string datPath = @"..\..\..\..\integration-testing\log4net2-SerializeEvent\SerializeV2Event.dat";
using var stream = File.OpenRead(datPath);
var formatter = new BinaryFormatter();
Expand Down
27 changes: 26 additions & 1 deletion src/log4net.Tests/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,40 @@
//
#endregion

using System;
using NUnit.Framework;

namespace log4net.Tests
{
/// <summary>
/// Summary description for Class1.
/// Utilities for testing
/// </summary>
public static class Utils
{
/// <summary>
/// Is the mono runtime used
/// </summary>
internal static bool IsMono { get; } = Type.GetType("Mono.Runtime") is not null;

/// <summary>
/// Skips the current test when run under mono
/// </summary>
internal static void InconclusiveOnMono()
{
if (IsMono)
{
Assert.Inconclusive("mono has a different behaviour");
}
}

/// <summary>
/// Sample property key
/// </summary>
internal const string PROPERTY_KEY = "prop1";

/// <summary>
/// Remove the <see cref="PROPERTY_KEY"/> from alle log4net contexts
/// </summary>
internal static void RemovePropertyFromAllContexts()
{
GlobalContext.Properties.Remove(PROPERTY_KEY);
Expand Down
2 changes: 1 addition & 1 deletion src/log4net/Appender/FileAppender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class FileAppender : TextWriterAppender
/// </summary>
private sealed class LockingStream : Stream, IDisposable
{
[Serializable]
[Log4NetSerializable]
public sealed class LockStateException : LogException
{
public LockStateException(string message)
Expand Down
2 changes: 1 addition & 1 deletion src/log4net/Config/AliasRepositoryAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace log4net.Config
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
[Serializable]
[Log4NetSerializable]
public sealed class AliasRepositoryAttribute : Attribute
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/log4net/Config/PluginAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace log4net.Config
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
[Serializable]
[Log4NetSerializable]
public sealed class PluginAttribute : Attribute, IPluginFactory
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/log4net/Config/RepositoryAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace log4net.Config
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
[AttributeUsage(AttributeTargets.Assembly)]
[Serializable]
[Log4NetSerializable]
public sealed class RepositoryAttribute : Attribute
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/log4net/Config/SecurityContextProviderAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace log4net.Config
/// </remarks>
/// <author>Nicko Cadell</author>
[AttributeUsage(AttributeTargets.Assembly)]
[Serializable]
[Log4NetSerializable]
public sealed class SecurityContextProviderAttribute : ConfiguratorAttribute
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/log4net/Config/XmlConfiguratorAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace log4net.Config
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
[AttributeUsage(AttributeTargets.Assembly)]
[Serializable]
[Log4NetSerializable]
public sealed class XmlConfiguratorAttribute : ConfiguratorAttribute
{
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/log4net/Core/Level.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ namespace log4net.Core;
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
[Serializable]
public class Level : IComparable, ISerializable, IEquatable<Level>, IComparable<Level>
[Log4NetSerializable]
public class Level : IComparable, ILog4NetSerializable, IEquatable<Level>, IComparable<Level>
{
/// <summary>
/// Constructor
Expand Down
4 changes: 2 additions & 2 deletions src/log4net/Core/LocationInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ namespace log4net.Core
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
[Serializable]
public class LocationInfo : ISerializable
[Log4NetSerializable]
public class LocationInfo : ILog4NetSerializable
{
/// <summary>
/// Constructor
Expand Down
Loading