Skip to content

Commit 0c1ef7f

Browse files
Add a .NET 8.0 target (#4884)
* 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
1 parent 6e14a0f commit 0c1ef7f

23 files changed

+212
-14
lines changed

CakeScripts.Tests/CakeScripts.Tests.csproj

+1-1
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>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77

CakeScripts/CakeScripts.csproj

+1-1
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>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>

nuget/framework/nunit.nuspec

+9-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525

2626
Supported platforms:
2727
- .NET Framework 4.6.2+
28-
- .NET 6.0+
28+
- .NET 6.0
29+
- .NET 8.0+
2930
</description>
3031
<releaseNotes>See release notes at https://docs.nunit.org/articles/nunit/release-notes/framework.html#nunit-400---november-26-2023</releaseNotes>
3132
<language>en-US</language>
@@ -38,6 +39,7 @@
3839
<dependency id="System.Memory" version="4.5.5" exclude="Build,Analyzers" />
3940
</group>
4041
<group targetFramework="net6.0" />
42+
<group targetFramework="net8.0" />
4143
</dependencies>
4244
</metadata>
4345
<files>
@@ -58,6 +60,12 @@
5860
<file src="bin/net6.0/nunit.framework.legacy.dll" target="lib\net6.0" />
5961
<file src="bin/net6.0/nunit.framework.legacy.xml" target="lib\net6.0" />
6062
<file src="bin/net6.0/nunit.framework.legacy.pdb" target="lib\net6.0" />
63+
<file src="bin/net8.0/nunit.framework.dll" target="lib\net8.0" />
64+
<file src="bin/net8.0/nunit.framework.xml" target="lib\net8.0" />
65+
<file src="bin/net8.0/nunit.framework.pdb" target="lib\net8.0" />
66+
<file src="bin/net8.0/nunit.framework.legacy.dll" target="lib\net8.0" />
67+
<file src="bin/net8.0/nunit.framework.legacy.pdb" target="lib\net8.0" />
68+
<file src="bin/net8.0/nunit.framework.legacy.xml" target="lib\net8.0" />
6169
<file src="..\..\nuget\framework\NUnit.props" target="build" />
6270
</files>
6371
</package>

nuget/nunitlite/nunitlite.nuspec

+3-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
Supported platforms:
1818
- .NET Framework 4.6.2+
19-
- .NET 6.0+
19+
- .NET 6.0
20+
- .NET 8.0+
2021

2122
How to use this package:
2223

@@ -34,9 +35,6 @@ How to use this package:
3435
<dependency id="NUnit" version="[$version$]" />
3536
</group>
3637
<group targetFramework="net8.0">
37-
<dependency id="NUnit" version="[$version$]" />
38-
</group>
39-
<group targetFramework="net9.0">
4038
<dependency id="NUnit" version="[$version$]" />
4139
</group>
4240
</dependencies>
@@ -52,7 +50,7 @@ How to use this package:
5250
<file src="bin/net462/nunitlite-runner.pdb" target="tools\net462" />
5351
<file src="bin/net6.0/nunitlite.dll" target="lib\net6.0" />
5452
<file src="bin/net6.0/nunitlite.pdb" target="lib\net6.0" />
55-
<file src="bin/net8.0/nunitlite.dll" target="lib\net8.0" />
53+
<file src="bin/net8.0/nunitlite.dll" target="lib\net8.0" />
5654
<file src="bin/net8.0/nunitlite.pdb" target="lib\net8.0" />
5755
</files>
5856
</package>

src/NUnitFramework/Directory.Build.props

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
<AssemblyOriginatorKeyFile>..\..\nunit.snk</AssemblyOriginatorKeyFile>
88
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
99
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
10-
<NUnitLibraryFrameworks>net462;net6.0</NUnitLibraryFrameworks>
10+
<NUnitLibraryFrameworks>net462;net6.0;net8.0</NUnitLibraryFrameworks>
1111
<NUnitRuntimeFrameworks>net462;net6.0;net8.0;net9.0</NUnitRuntimeFrameworks>
1212
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
1313
<!--<OutputPath>..\..\..\bin\$(Configuration)\</OutputPath>-->
1414
<CheckEolTargetFramework>false</CheckEolTargetFramework>
1515
<Nullable>enable</Nullable>
16-
<AnnotatedReferenceAssemblyVersion>7.0.0</AnnotatedReferenceAssemblyVersion>
16+
<AnnotatedReferenceAssemblyVersion>8.0.0</AnnotatedReferenceAssemblyVersion>
1717
<GenerateNullableAttributes>false</GenerateNullableAttributes>
1818
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
1919
<CsWinRTAotOptimizerEnabled>false</CsWinRTAotOptimizerEnabled>

src/NUnitFramework/framework/Exceptions/AssertionException.cs

+2
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ public AssertionException(string message, Exception? inner) : base(message, inne
2626
{
2727
}
2828

29+
#if !NET8_0_OR_GREATER
2930
/// <summary>
3031
/// Serialization Constructor
3132
/// </summary>
3233
protected AssertionException(System.Runtime.Serialization.SerializationInfo info,
3334
System.Runtime.Serialization.StreamingContext context) : base(info, context)
3435
{
3536
}
37+
#endif
3638

3739
/// <summary>
3840
/// Gets the ResultState provided by this exception

src/NUnitFramework/framework/Exceptions/IgnoreException.cs

+2
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ public IgnoreException(string message, Exception? inner) : base(message, inner)
2525
{
2626
}
2727

28+
#if !NET8_0_OR_GREATER
2829
/// <summary>
2930
/// Serialization Constructor
3031
/// </summary>
3132
protected IgnoreException(System.Runtime.Serialization.SerializationInfo info,
3233
System.Runtime.Serialization.StreamingContext context) : base(info, context)
3334
{
3435
}
36+
#endif
3537

3638
/// <summary>
3739
/// Gets the ResultState provided by this exception

src/NUnitFramework/framework/Exceptions/InconclusiveException.cs

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public InconclusiveException(string message, Exception? inner)
2828
{
2929
}
3030

31+
#if !NET8_0_OR_GREATER
3132
/// <summary>
3233
/// Serialization Constructor
3334
/// </summary>
@@ -36,6 +37,7 @@ protected InconclusiveException(System.Runtime.Serialization.SerializationInfo i
3637
: base(info, context)
3738
{
3839
}
40+
#endif
3941

4042
/// <summary>
4143
/// Gets the ResultState provided by this exception

src/NUnitFramework/framework/Exceptions/MultipleAssertException.cs

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public MultipleAssertException(ITestResult testResult)
2828
TestResult = testResult;
2929
}
3030

31+
#if !NET8_0_OR_GREATER
3132
#pragma warning disable CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable.
3233
/// <summary>
3334
/// Serialization Constructor
@@ -37,6 +38,7 @@ protected MultipleAssertException(System.Runtime.Serialization.SerializationInfo
3738
{
3839
}
3940
#pragma warning restore CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable.
41+
#endif
4042

4143
/// <summary>
4244
/// Gets the <see cref="ResultState"/> provided by this exception.

src/NUnitFramework/framework/Exceptions/ResultStateException.cs

+2
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ public ResultStateException(string message, Exception? inner) : base(message, in
2626
{
2727
}
2828

29+
#if !NET8_0_OR_GREATER
2930
/// <summary>
3031
/// Serialization Constructor
3132
/// </summary>
3233
protected ResultStateException(System.Runtime.Serialization.SerializationInfo info,
3334
System.Runtime.Serialization.StreamingContext context) : base(info, context)
3435
{
3536
}
37+
#endif
3638

3739
/// <summary>
3840
/// Gets the ResultState provided by this exception

src/NUnitFramework/framework/Exceptions/SuccessException.cs

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public SuccessException(string message, Exception? inner)
2727
{
2828
}
2929

30+
#if !NET8_0_OR_GREATER
3031
/// <summary>
3132
/// Serialization Constructor
3233
/// </summary>
@@ -35,6 +36,7 @@ protected SuccessException(System.Runtime.Serialization.SerializationInfo info,
3536
: base(info, context)
3637
{
3738
}
39+
#endif
3840

3941
/// <summary>
4042
/// Gets the ResultState provided by this exception

src/NUnitFramework/framework/Internal/InvalidDataSourceException.cs

+4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
namespace NUnit.Framework.Internal
44
{
55
using System;
6+
#if !NET8_0_OR_GREATER
67
using System.Runtime.Serialization;
8+
#endif
79

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

41+
#if !NET8_0_OR_GREATER
3942
/// <summary>
4043
/// Serialization Constructor
4144
/// </summary>
4245
protected InvalidDataSourceException(SerializationInfo info,
4346
StreamingContext context) : base(info, context)
4447
{
4548
}
49+
#endif
4650
}
4751
}

src/NUnitFramework/framework/Internal/InvalidPlatformException.cs

+4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt
22

33
using System;
4+
#if !NET8_0_OR_GREATER
45
using System.Runtime.Serialization;
6+
#endif
57

68
namespace NUnit.Framework.Internal
79
{
@@ -36,12 +38,14 @@ public InvalidPlatformException(string message, Exception inner) : base(message,
3638
{
3739
}
3840

41+
#if !NET8_0_OR_GREATER
3942
/// <summary>
4043
/// Serialization constructor for the <see cref="InvalidPlatformException"/> class
4144
/// </summary>
4245
protected InvalidPlatformException(SerializationInfo info, StreamingContext context)
4346
: base(info, context)
4447
{
4548
}
49+
#endif
4650
}
4751
}

src/NUnitFramework/framework/Internal/InvalidTestFixtureException.cs

+4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
namespace NUnit.Framework.Internal
44
{
55
using System;
6+
#if !NET8_0_OR_GREATER
67
using System.Runtime.Serialization;
8+
#endif
79

810
/// <summary>
911
/// InvalidTestFixtureException is thrown when an appropriate test
@@ -36,12 +38,14 @@ public InvalidTestFixtureException(string message, Exception inner) : base(messa
3638
{
3739
}
3840

41+
#if !NET8_0_OR_GREATER
3942
/// <summary>
4043
/// Serialization Constructor
4144
/// </summary>
4245
protected InvalidTestFixtureException(SerializationInfo info,
4346
StreamingContext context) : base(info, context)
4447
{
4548
}
49+
#endif
4650
}
4751
}

src/NUnitFramework/framework/Internal/MethodWrapper.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public override string ToString()
159159
/// <inheritdoc />
160160
public bool Equals(MethodWrapper? other)
161161
{
162-
if (ReferenceEquals(null, other))
162+
if (other is null)
163163
{
164164
return false;
165165
}
@@ -175,7 +175,7 @@ public bool Equals(MethodWrapper? other)
175175
/// <inheritdoc />
176176
public override bool Equals(object? obj)
177177
{
178-
if (ReferenceEquals(null, obj))
178+
if (obj is null)
179179
{
180180
return false;
181181
}

src/NUnitFramework/framework/Internal/NUnitException.cs

+4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
namespace NUnit.Framework.Internal
44
{
55
using System;
6+
#if !NET8_0_OR_GREATER
67
using System.Runtime.Serialization;
8+
#endif
79

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

45+
#if !NET8_0_OR_GREATER
4346
/// <summary>
4447
/// Serialization Constructor
4548
/// </summary>
4649
protected NUnitException(SerializationInfo info,
4750
StreamingContext context) : base(info, context)
4851
{
4952
}
53+
#endif
5054
}
5155
}

src/NUnitFramework/framework/Internal/TestCaseTimeoutException.cs

+4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
namespace NUnit.Framework.Internal
44
{
55
using System;
6+
#if !NET8_0_OR_GREATER
67
using System.Runtime.Serialization;
8+
#endif
79

810
/// <summary>
911
/// TestCaseTimeoutException is thrown when a test running directly
@@ -36,12 +38,14 @@ public TestCaseTimeoutException(string message, Exception inner) : base(message,
3638
{
3739
}
3840

41+
#if !NET8_0_OR_GREATER
3942
/// <summary>
4043
/// Serialization Constructor
4144
/// </summary>
4245
protected TestCaseTimeoutException(SerializationInfo info,
4346
StreamingContext context) : base(info, context)
4447
{
4548
}
49+
#endif
4650
}
4751
}

src/NUnitFramework/nunitlite/Options.cs

+8
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,12 @@
134134
using System.Collections.ObjectModel;
135135
using System.ComponentModel;
136136
using System.IO;
137+
#if !NET8_0_OR_GREATER
137138
using System.Runtime.Serialization;
139+
#if !NET6_0_OR_GREATER
138140
using System.Security.Permissions;
141+
#endif
142+
#endif
139143
using System.Text;
140144
using System.Text.RegularExpressions;
141145

@@ -569,14 +573,17 @@ public OptionException(string message, string optionName, Exception innerExcepti
569573
_option = optionName;
570574
}
571575

576+
#if !NET8_0_OR_GREATER
572577
protected OptionException(SerializationInfo info, StreamingContext context)
573578
: base(info, context)
574579
{
575580
_option = info.GetString("OptionName");
576581
}
582+
#endif
577583

578584
public string OptionName => _option;
579585

586+
#if !NET8_0_OR_GREATER
580587
#if !NET6_0_OR_GREATER
581588
[SecurityPermission(SecurityAction.LinkDemand, SerializationFormatter = true)]
582589
#endif
@@ -585,6 +592,7 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
585592
base.GetObjectData(info, context);
586593
info.AddValue("OptionName", _option);
587594
}
595+
#endif
588596
}
589597

590598
public delegate void OptionAction<TKey, TValue>(TKey key, TValue value);

src/NUnitFramework/nunitlite/OutputWriters/OutputWriter.cs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public abstract class OutputWriter
2121
/// <param name="result">The result to be written</param>
2222
/// <param name="outputPath">Path to the file to which the result is written</param>
2323
/// <param name="runSettings">A dictionary of settings used for this test run</param>
24+
/// <param name="filter">The filter to apply</param>
2425
public void WriteResultFile(ITestResult result, string outputPath, IDictionary<string, object> runSettings, TestFilter filter)
2526
{
2627
using (var stream = new FileStream(outputPath, FileMode.Create))

0 commit comments

Comments
 (0)