Skip to content

Commit

Permalink
Add a .NET 8.0 target (#4884)
Browse files Browse the repository at this point in the history
* Add a .NET 8.0 target

* Added test to ensure we no longer forget to update libraries in .nuspec files.

* Stupid backslashes in directory separators
  • Loading branch information
manfred-brands authored Nov 26, 2024
1 parent 6e14a0f commit 0c1ef7f
Show file tree
Hide file tree
Showing 23 changed files with 212 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CakeScripts.Tests/CakeScripts.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
2 changes: 1 addition & 1 deletion CakeScripts/CakeScripts.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
10 changes: 9 additions & 1 deletion nuget/framework/nunit.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

Supported platforms:
- .NET Framework 4.6.2+
- .NET 6.0+
- .NET 6.0
- .NET 8.0+
</description>
<releaseNotes>See release notes at https://docs.nunit.org/articles/nunit/release-notes/framework.html#nunit-400---november-26-2023</releaseNotes>
<language>en-US</language>
Expand All @@ -38,6 +39,7 @@
<dependency id="System.Memory" version="4.5.5" exclude="Build,Analyzers" />
</group>
<group targetFramework="net6.0" />
<group targetFramework="net8.0" />
</dependencies>
</metadata>
<files>
Expand All @@ -58,6 +60,12 @@
<file src="bin/net6.0/nunit.framework.legacy.dll" target="lib\net6.0" />
<file src="bin/net6.0/nunit.framework.legacy.xml" target="lib\net6.0" />
<file src="bin/net6.0/nunit.framework.legacy.pdb" target="lib\net6.0" />
<file src="bin/net8.0/nunit.framework.dll" target="lib\net8.0" />
<file src="bin/net8.0/nunit.framework.xml" target="lib\net8.0" />
<file src="bin/net8.0/nunit.framework.pdb" target="lib\net8.0" />
<file src="bin/net8.0/nunit.framework.legacy.dll" target="lib\net8.0" />
<file src="bin/net8.0/nunit.framework.legacy.pdb" target="lib\net8.0" />
<file src="bin/net8.0/nunit.framework.legacy.xml" target="lib\net8.0" />
<file src="..\..\nuget\framework\NUnit.props" target="build" />
</files>
</package>
8 changes: 3 additions & 5 deletions nuget/nunitlite/nunitlite.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

Supported platforms:
- .NET Framework 4.6.2+
- .NET 6.0+
- .NET 6.0
- .NET 8.0+

How to use this package:

Expand All @@ -34,9 +35,6 @@ How to use this package:
<dependency id="NUnit" version="[$version$]" />
</group>
<group targetFramework="net8.0">
<dependency id="NUnit" version="[$version$]" />
</group>
<group targetFramework="net9.0">
<dependency id="NUnit" version="[$version$]" />
</group>
</dependencies>
Expand All @@ -52,7 +50,7 @@ How to use this package:
<file src="bin/net462/nunitlite-runner.pdb" target="tools\net462" />
<file src="bin/net6.0/nunitlite.dll" target="lib\net6.0" />
<file src="bin/net6.0/nunitlite.pdb" target="lib\net6.0" />
<file src="bin/net8.0/nunitlite.dll" target="lib\net8.0" />
<file src="bin/net8.0/nunitlite.dll" target="lib\net8.0" />
<file src="bin/net8.0/nunitlite.pdb" target="lib\net8.0" />
</files>
</package>
4 changes: 2 additions & 2 deletions src/NUnitFramework/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<AssemblyOriginatorKeyFile>..\..\nunit.snk</AssemblyOriginatorKeyFile>
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<NUnitLibraryFrameworks>net462;net6.0</NUnitLibraryFrameworks>
<NUnitLibraryFrameworks>net462;net6.0;net8.0</NUnitLibraryFrameworks>
<NUnitRuntimeFrameworks>net462;net6.0;net8.0;net9.0</NUnitRuntimeFrameworks>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<!--<OutputPath>..\..\..\bin\$(Configuration)\</OutputPath>-->
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<Nullable>enable</Nullable>
<AnnotatedReferenceAssemblyVersion>7.0.0</AnnotatedReferenceAssemblyVersion>
<AnnotatedReferenceAssemblyVersion>8.0.0</AnnotatedReferenceAssemblyVersion>
<GenerateNullableAttributes>false</GenerateNullableAttributes>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CsWinRTAotOptimizerEnabled>false</CsWinRTAotOptimizerEnabled>
Expand Down
2 changes: 2 additions & 0 deletions src/NUnitFramework/framework/Exceptions/AssertionException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ public AssertionException(string message, Exception? inner) : base(message, inne
{
}

#if !NET8_0_OR_GREATER
/// <summary>
/// Serialization Constructor
/// </summary>
protected AssertionException(System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context) : base(info, context)
{
}
#endif

/// <summary>
/// Gets the ResultState provided by this exception
Expand Down
2 changes: 2 additions & 0 deletions src/NUnitFramework/framework/Exceptions/IgnoreException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ public IgnoreException(string message, Exception? inner) : base(message, inner)
{
}

#if !NET8_0_OR_GREATER
/// <summary>
/// Serialization Constructor
/// </summary>
protected IgnoreException(System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context) : base(info, context)
{
}
#endif

/// <summary>
/// Gets the ResultState provided by this exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public InconclusiveException(string message, Exception? inner)
{
}

#if !NET8_0_OR_GREATER
/// <summary>
/// Serialization Constructor
/// </summary>
Expand All @@ -36,6 +37,7 @@ protected InconclusiveException(System.Runtime.Serialization.SerializationInfo i
: base(info, context)
{
}
#endif

/// <summary>
/// Gets the ResultState provided by this exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public MultipleAssertException(ITestResult testResult)
TestResult = testResult;
}

#if !NET8_0_OR_GREATER
#pragma warning disable CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable.
/// <summary>
/// Serialization Constructor
Expand All @@ -37,6 +38,7 @@ protected MultipleAssertException(System.Runtime.Serialization.SerializationInfo
{
}
#pragma warning restore CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable.
#endif

/// <summary>
/// Gets the <see cref="ResultState"/> provided by this exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ public ResultStateException(string message, Exception? inner) : base(message, in
{
}

#if !NET8_0_OR_GREATER
/// <summary>
/// Serialization Constructor
/// </summary>
protected ResultStateException(System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context) : base(info, context)
{
}
#endif

/// <summary>
/// Gets the ResultState provided by this exception
Expand Down
2 changes: 2 additions & 0 deletions src/NUnitFramework/framework/Exceptions/SuccessException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public SuccessException(string message, Exception? inner)
{
}

#if !NET8_0_OR_GREATER
/// <summary>
/// Serialization Constructor
/// </summary>
Expand All @@ -35,6 +36,7 @@ protected SuccessException(System.Runtime.Serialization.SerializationInfo info,
: base(info, context)
{
}
#endif

/// <summary>
/// Gets the ResultState provided by this exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace NUnit.Framework.Internal
{
using System;
#if !NET8_0_OR_GREATER
using System.Runtime.Serialization;
#endif

/// <summary>
/// InvalidTestFixtureException is thrown when an appropriate test
Expand Down Expand Up @@ -36,12 +38,14 @@ public InvalidDataSourceException(string message, Exception inner) : base(messag
{
}

#if !NET8_0_OR_GREATER
/// <summary>
/// Serialization Constructor
/// </summary>
protected InvalidDataSourceException(SerializationInfo info,
StreamingContext context) : base(info, context)
{
}
#endif
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

using System;
#if !NET8_0_OR_GREATER
using System.Runtime.Serialization;
#endif

namespace NUnit.Framework.Internal
{
Expand Down Expand Up @@ -36,12 +38,14 @@ public InvalidPlatformException(string message, Exception inner) : base(message,
{
}

#if !NET8_0_OR_GREATER
/// <summary>
/// Serialization constructor for the <see cref="InvalidPlatformException"/> class
/// </summary>
protected InvalidPlatformException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace NUnit.Framework.Internal
{
using System;
#if !NET8_0_OR_GREATER
using System.Runtime.Serialization;
#endif

/// <summary>
/// InvalidTestFixtureException is thrown when an appropriate test
Expand Down Expand Up @@ -36,12 +38,14 @@ public InvalidTestFixtureException(string message, Exception inner) : base(messa
{
}

#if !NET8_0_OR_GREATER
/// <summary>
/// Serialization Constructor
/// </summary>
protected InvalidTestFixtureException(SerializationInfo info,
StreamingContext context) : base(info, context)
{
}
#endif
}
}
4 changes: 2 additions & 2 deletions src/NUnitFramework/framework/Internal/MethodWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public override string ToString()
/// <inheritdoc />
public bool Equals(MethodWrapper? other)
{
if (ReferenceEquals(null, other))
if (other is null)
{
return false;
}
Expand All @@ -175,7 +175,7 @@ public bool Equals(MethodWrapper? other)
/// <inheritdoc />
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj))
if (obj is null)
{
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions src/NUnitFramework/framework/Internal/NUnitException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace NUnit.Framework.Internal
{
using System;
#if !NET8_0_OR_GREATER
using System.Runtime.Serialization;
#endif

/// <summary>
/// Thrown when an assertion failed. Here to preserve the inner
Expand Down Expand Up @@ -40,12 +42,14 @@ public NUnitException(string message, Exception? inner)
{
}

#if !NET8_0_OR_GREATER
/// <summary>
/// Serialization Constructor
/// </summary>
protected NUnitException(SerializationInfo info,
StreamingContext context) : base(info, context)
{
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace NUnit.Framework.Internal
{
using System;
#if !NET8_0_OR_GREATER
using System.Runtime.Serialization;
#endif

/// <summary>
/// TestCaseTimeoutException is thrown when a test running directly
Expand Down Expand Up @@ -36,12 +38,14 @@ public TestCaseTimeoutException(string message, Exception inner) : base(message,
{
}

#if !NET8_0_OR_GREATER
/// <summary>
/// Serialization Constructor
/// </summary>
protected TestCaseTimeoutException(SerializationInfo info,
StreamingContext context) : base(info, context)
{
}
#endif
}
}
8 changes: 8 additions & 0 deletions src/NUnitFramework/nunitlite/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,12 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
#if !NET8_0_OR_GREATER
using System.Runtime.Serialization;
#if !NET6_0_OR_GREATER
using System.Security.Permissions;
#endif
#endif
using System.Text;
using System.Text.RegularExpressions;

Expand Down Expand Up @@ -569,14 +573,17 @@ public OptionException(string message, string optionName, Exception innerExcepti
_option = optionName;
}

#if !NET8_0_OR_GREATER
protected OptionException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
_option = info.GetString("OptionName");
}
#endif

public string OptionName => _option;

#if !NET8_0_OR_GREATER
#if !NET6_0_OR_GREATER
[SecurityPermission(SecurityAction.LinkDemand, SerializationFormatter = true)]
#endif
Expand All @@ -585,6 +592,7 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
base.GetObjectData(info, context);
info.AddValue("OptionName", _option);
}
#endif
}

public delegate void OptionAction<TKey, TValue>(TKey key, TValue value);
Expand Down
1 change: 1 addition & 0 deletions src/NUnitFramework/nunitlite/OutputWriters/OutputWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public abstract class OutputWriter
/// <param name="result">The result to be written</param>
/// <param name="outputPath">Path to the file to which the result is written</param>
/// <param name="runSettings">A dictionary of settings used for this test run</param>
/// <param name="filter">The filter to apply</param>
public void WriteResultFile(ITestResult result, string outputPath, IDictionary<string, object> runSettings, TestFilter filter)
{
using (var stream = new FileStream(outputPath, FileMode.Create))
Expand Down
Loading

0 comments on commit 0c1ef7f

Please sign in to comment.