Skip to content

Commit

Permalink
Updatepackages and fix warnings (#4629)
Browse files Browse the repository at this point in the history
* updating packages

* Update packages and fix warnings

* Fixing PR comments

* Fixed more warnings

* Undo changes to NUnit.Analyzer PackageReference

* Remove/Move some NUnit suppression

This as a result of updating the version of the NUnit.Analyzer

* Undo changes to CodeStyle package reference

---------

Co-authored-by: Manfred Brands <manfred-brands@users.noreply.github.com>
  • Loading branch information
OsirisTerje and manfred-brands committed Feb 19, 2024
1 parent 1ad9a85 commit d96485a
Show file tree
Hide file tree
Showing 30 changed files with 132 additions and 97 deletions.
1 change: 1 addition & 0 deletions NUnit.sln.DotSettings
Expand Up @@ -44,6 +44,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=03c58a20_002Df24c_002D4992_002Da01b_002Dd4dd88b40443/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Private, Internal" Description="Non-visible static readonly and constant fields"&gt;&lt;ElementKinds&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;Kind Name="CONSTANT_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="False" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=7aea095d_002Df375_002D4eae_002Da93c_002Dc735520887c6/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static, Instance" AccessRightKinds="Protected, ProtectedInternal, Public" Description="Visible fields"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;Kind Name="CONSTANT_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"&gt;&lt;ExtraRule Prefix="" Suffix="" Style="AA_BB" /&gt;&lt;/Policy&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=a75d9d04_002Dddc9_002D4c5e_002Da636_002D844e5ce42835/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static, Instance" AccessRightKinds="Internal" Description="Internal fields"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;Kind Name="CONSTANT_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="False" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EFeature_002EServices_002ECodeCleanup_002EFileHeader_002EFileHeaderSettingsMigrate/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
Expand Down
2 changes: 1 addition & 1 deletion src/NUnitFramework/Directory.Build.props
Expand Up @@ -38,7 +38,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
<PackageReference Include="DotNetAnalyzers.DocumentationAnalyzers" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" PrivateAssets="all" />
<PackageReference Include="IsExternalInit" PrivateAssets="all" />
<PackageReference Include="Nullable" PrivateAssets="all" />
<PackageReference Include="CSharpIsNullAnalyzer" PrivateAssets="all" />
Expand Down
20 changes: 6 additions & 14 deletions src/NUnitFramework/Directory.Packages.props
Expand Up @@ -3,21 +3,18 @@
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
<EnablePackageVersionOverride>false</EnablePackageVersionOverride>
</PropertyGroup>

<!-- Packages for used features -->
<ItemGroup>
<PackageVersion Include="System.Collections.Immutable" Version="6.0.0" />
<PackageVersion Include="System.ValueTuple" version="4.5.0" />
</ItemGroup>

<!-- General Packages -->
<ItemGroup>
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageVersion Include="FSharp.Core" Version="7.0.200" />
</ItemGroup>

<!-- Package to allow Nullability etc. in older SDKS -->
<ItemGroup>
<PackageVersion Include="IsExternalInit" Version="1.0.3" />
Expand All @@ -26,28 +23,23 @@
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="7.0.0" />
<PackageVersion Include="TunnelVisionLabs.ReferenceAssemblyAnnotator" Version="1.0.0-alpha.160" />
</ItemGroup>

<!-- Analyzers -->
<ItemGroup>
<PackageVersion Include="CSharpIsNullAnalyzer" Version="0.1.495" />
<PackageVersion Include="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.59" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.6.0" />
<PackageVersion Include="NUnit.Analyzers" Version="3.9.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.8.0" />
<PackageVersion Include="NUnit.Analyzers" Version="4.0.1" />
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.507" />
</ItemGroup>

<!-- Specific dependencies -->
<ItemGroup>
<PackageVersion Include="BenchmarkDotNet" Version="0.13.5" />
<PackageVersion Include="BenchmarkDotNet" Version="0.13.12" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<PackageVersion Include="System.Security.Principal.Windows" Version="5.0.0" />
</ItemGroup>

<!-- Explictily set the version of indirect referenced nuget packages -->
<ItemGroup>
<PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
</ItemGroup>

</Project>
</Project>
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand Down
2 changes: 2 additions & 0 deletions src/NUnitFramework/mock-assembly/mock-assembly.csproj
Expand Up @@ -4,6 +4,8 @@
<TargetFrameworks>$(NUnitRuntimeFrameworks)</TargetFrameworks>
<RootNamespace>NUnit.Tests</RootNamespace>
<IsTestProject>false</IsTestProject>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
13 changes: 13 additions & 0 deletions src/NUnitFramework/nunit.framework.legacy.tests/.editorconfig
@@ -0,0 +1,13 @@

[*.cs]

dotnet_diagnostic.NUnit2003.severity = none
dotnet_diagnostic.NUnit2005.severity = none
dotnet_diagnostic.NUnit2006.severity = none
dotnet_diagnostic.NUnit2007.severity = none
dotnet_diagnostic.NUnit2018.severity = none
dotnet_diagnostic.NUnit2031.severity = none
dotnet_diagnostic.NUnit2048.severity = none
dotnet_diagnostic.NUnit2049.severity = none


Expand Up @@ -518,9 +518,7 @@ public void IEquatableSuccess_ConstraintSyntax()
Assert.Multiple(() =>
{
Assert.That(a, Is.EqualTo(1));
#pragma warning disable NUnit2007 // The actual value should not be a constant
Assert.That(1, Is.EqualTo(a));
#pragma warning restore NUnit2007 // The actual value should not be a constant
});
}

Expand Down
Expand Up @@ -245,7 +245,7 @@ public void AreEqual_UsingIterator()
{
int[] array = new int[] { 1, 2, 3 };

CollectionAssert.AreEqual(array, CountToThree());
CollectionAssert.AreEqual(array, CollectionAssertTest.CountToThree());
}

[Test]
Expand Down Expand Up @@ -277,7 +277,7 @@ public void ArraysAreEqualWithCollectionsObjectsImplementingIEquatable()
CollectionAssert.AreEqual(set1, set2);
}

private IEnumerable CountToThree()
private static IEnumerable CountToThree()
{
yield return 1;
yield return 2;
Expand All @@ -290,7 +290,7 @@ public void AreEqual_UsingIterator_Fails()
int[] array = new int[] { 1, 3, 5 };

AssertionException? ex = Assert.Throws<AssertionException>(
delegate { CollectionAssert.AreEqual(array, CountToThree()); });
delegate { CollectionAssert.AreEqual(array, CollectionAssertTest.CountToThree()); });

Assert.That(ex?.Message, Does.Contain("Values differ at index [1]").And.
Contains("Expected: 3").And.
Expand Down
Expand Up @@ -2,10 +2,9 @@

using System;
using System.IO;
using NUnit.Framework.Legacy;
using NUnit.Framework.Tests.TestUtilities;

namespace NUnit.Framework.Tests.Assertions
namespace NUnit.Framework.Legacy.Tests
{
[TestFixture]
public class DirectoryAssertTests
Expand Down
Expand Up @@ -2,10 +2,9 @@

using System;
using System.IO;
using NUnit.Framework.Legacy;
using NUnit.Framework.Tests.TestUtilities;

namespace NUnit.Framework.Tests.Assertions
namespace NUnit.Framework.Legacy.Tests
{
/// <summary>
/// Summary description for FileAssertTests.
Expand Down
Expand Up @@ -3,7 +3,7 @@
using System;
using NUnit.Framework.Tests.Assertions;

namespace NUnit.Framework.Tests.ClassicAssertions
namespace NUnit.Framework.Legacy.Tests
{
[TestFixture]
public class NotEqualFixture
Expand Down
Expand Up @@ -3,7 +3,7 @@
using System;
using NUnit.Framework.Tests.Assertions;

namespace NUnit.Framework.Tests.ClassicAssertions
namespace NUnit.Framework.Legacy.Tests
{
[TestFixture]
public class NotSameFixture
Expand Down
Expand Up @@ -2,9 +2,8 @@

using System;
using NUnit.Framework.Internal;
using NUnit.Framework.Legacy;

namespace NUnit.Framework.Tests.Assertions
namespace NUnit.Framework.Legacy.Tests
{
[TestFixture]
public class StringAssertTests
Expand Down
Expand Up @@ -9,6 +9,8 @@
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<IsTestProject>true</IsTestProject>
<IsPackable>false</IsPackable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/NUnitFramework/nunitlite-runner/nunitlite-runner.csproj
Expand Up @@ -4,6 +4,7 @@
<OutputType>Exe</OutputType>
<RootNamespace>NUnitLite</RootNamespace>
<TargetFrameworks>$(NUnitRuntimeFrameworks)</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
Expand All @@ -15,4 +16,5 @@
<ProjectReference Include="..\framework\nunit.framework.csproj" />
<ProjectReference Include="..\nunitlite\nunitlite.csproj" />
</ItemGroup>

</Project>
4 changes: 3 additions & 1 deletion src/NUnitFramework/nunitlite.tests/nunitlite.tests.csproj
Expand Up @@ -5,6 +5,8 @@
<RootNamespace>NUnitLite.Tests</RootNamespace>
<TargetFrameworks>$(NUnitRuntimeFrameworks)</TargetFrameworks>
<Nullable>disable</Nullable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand All @@ -22,7 +24,7 @@
<EmbeddedResource Include="TestListFile2.txt" />
</ItemGroup>

<ItemGroup>
<ItemGroup>
<PackageReference Include="NUnit.Analyzers" />
</ItemGroup>

Expand Down
2 changes: 2 additions & 0 deletions src/NUnitFramework/slow-tests/slow-nunit-tests.csproj
Expand Up @@ -3,6 +3,8 @@
<PropertyGroup>
<TargetFrameworks>$(NUnitRuntimeFrameworks)</TargetFrameworks>
<RootNamespace>NUnit.Tests</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion src/NUnitFramework/testdata/TestFixtureData.cs
Expand Up @@ -9,7 +9,6 @@ namespace NUnit.TestData.TestFixtureTests
/// <summary>
/// Classes used for testing NUnit
/// </summary>

[TestFixture]
public class RegularFixtureWithOneTest
{
Expand Down
2 changes: 2 additions & 0 deletions src/NUnitFramework/testdata/nunit.testdata.csproj
Expand Up @@ -5,6 +5,8 @@
<TargetFrameworks>$(NUnitRuntimeFrameworks)</TargetFrameworks>
<Optimize>false</Optimize>
<IsTestProject>false</IsTestProject>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
Expand Down
9 changes: 6 additions & 3 deletions src/NUnitFramework/tests/Assertions/AssertThatTests.cs
Expand Up @@ -228,7 +228,9 @@ string GetExceptionMessage()

// Act
#pragma warning disable NUnit2045 // Use Assert.Multiple
#pragma warning disable NUnit2010 // Use EqualConstraint for better assertion messages in case of failure
Assert.That(0 + 1 == 1, GetExceptionMessage);
#pragma warning restore NUnit2010 // Use EqualConstraint for better assertion messages in case of failure
#pragma warning restore NUnit2045 // Use Assert.Multiple

// Assert
Expand All @@ -248,7 +250,9 @@ string GetExceptionMessage()
}

// Act
#pragma warning disable NUnit2010 // Use EqualConstraint for better assertion messages in case of failure
var ex = Assert.Throws<AssertionException>(() => Assert.That(1 + 1 == 1, GetExceptionMessage));
#pragma warning restore NUnit2010 // Use EqualConstraint for better assertion messages in case of failure

// Assert
Assert.That(ex?.Message, Does.Contain("Func was called"));
Expand Down Expand Up @@ -366,9 +370,6 @@ public void AssertThatWithTypesNotSupportingTolerance(object? x, object? y)
Throws.InstanceOf<NotSupportedException>().With.Message.Contains("Tolerance"));
}

// TODO: Remove when NUnit.Analyzer 3.10 is released.
#pragma warning disable NUnit2047 // Incompatible types for Within constraint

[Test]
public void AssertThatEqualsWithClassWithSomeToleranceAwareMembers()
{
Expand Down Expand Up @@ -499,10 +500,12 @@ public void AssertThatEqualsWithRecord()
Assert.That(new SomeRecord(1, 1.1, "2.2", zero), Is.Not.EqualTo(instance));
Assert.That(new SomeRecord(1, 2.2, "1.1", zero), Is.Not.EqualTo(instance));
Assert.That(new SomeRecord(2, 1.1, "1.1", zero), Is.Not.EqualTo(instance));
#pragma warning disable NUnit2047 // Incompatible types for Within constraint
Assert.That(() =>
Assert.That(new SomeRecord(1, 1.2, "1.1", zero),
Is.EqualTo(instance).Within(0.1)),
Throws.InstanceOf<NotSupportedException>().With.Message.Contains("Tolerance"));
#pragma warning restore NUnit2047 // Incompatible types for Within constraint
});
}

Expand Down
3 changes: 0 additions & 3 deletions src/NUnitFramework/tests/Assertions/ListContentsTests.cs
Expand Up @@ -136,9 +136,6 @@ public void ContainsItemUsing()
Assert.That(collection1, constraint);
}

// https://github.com/nunit/nunit.analyzers/issues/621
#pragma warning disable NUnit2025 // Wrong actual type used with ContainsConstraint

[Test]
public void ContainsNullability()
{
Expand Down
9 changes: 7 additions & 2 deletions src/NUnitFramework/tests/Assertions/NullableTypesTests.cs
@@ -1,5 +1,10 @@
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

#pragma warning disable NUnit2005
#pragma warning disable NUnit2017
#pragma warning disable NUnit2019
#pragma warning disable NUnit2045

namespace NUnit.Framework.Tests.Assertions
{
[TestFixture, Category("Generics")]
Expand Down Expand Up @@ -201,8 +206,8 @@ public MyStruct(int i, string s)
[Test]
public void CanCompareNullableStructs()
{
MyStruct struct1 = new MyStruct(5, "Hello");
MyStruct struct2 = new MyStruct(5, "Hello");
var struct1 = new MyStruct(5, "Hello");
var struct2 = new MyStruct(5, "Hello");
MyStruct? one = new MyStruct(5, "Hello");
MyStruct? two = new MyStruct(5, "Hello");

Expand Down

0 comments on commit d96485a

Please sign in to comment.